I need to know if its possible to concatenate strings, as follows ? and if not, what is the alternative of doing so ?
while ($personCount < 10) {
$result+= $personCount . "person ";
}
echo $result;
it should appear like 1 person 2 person 3
person etc..
You cann't use the +
sign in concatenation so what is the alternative ?
I think this code should work fine
That is the proper answer I think because PHP is forced to re-concatenate with every '.' operator. It is better to use double quotes to concatenate.
This should be faster.
Just use
.
for concatenating. And you missed out the$personCount
increment!