PHP string concatenation
One step (IMHO) better
$result .= $personCount . ' people';
while ($personCount < 10) {
$result .= ($personCount++)." people ";
}
echo $result;
Just use .
for concatenating.
And you missed out the $personCount
increment!
while ($personCount < 10) {
$result .= $personCount . ' people';
$personCount++;
}
echo $result;
This should be faster.
while ($personCount < 10) {
$result .= "{$personCount} people ";
$personCount++;
}
echo $result;