Appending to a single string is easy:
$string = "saucy";
$output = " you smell ". $string;
print $output;
// you smell saucy.
PHP also has a easy way of setting multiple values at once:
$aa = $bb = $cc = [];
But what if I want to append a string to multiple strings simultaneously?
For example:
$aa['horses'] = "trolls!";
$stringSomething = "This is better: ";
$stringElse = "This is less worse : ";
foreach($aa as $bb){
$stringSomething .= $stringElse .= $bb; // THIS line
}
print $stringSomething;
print $stringElse;
This outputs:
This is better: This is less worse : trolls!
This is less worse : trolls!
What I am curious about is if you can have an output like this:
This is better: trolls!
This is less worse : trolls!
Currently all I can see is:
foreach($aa as $bb){
$stringSomething .= $bb;
$stringElse .= $bb;
$stringEntirely .= $bb;
// ....
}
Is there a way of wrapping this all up into a single line of appending the same value to multiple strings at once?
NOTE
The question here is NOT "How can I do this on an array", it is asking if there was a shorthand way of doing this with variables, as is possible with initial variable setting ( ie $a = $b = $c = 67;).
$stringsarray with elements under keysSomething,ElseandEntirelythen in this particular instance :-)