[php] PHP string concatenation

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 ?

This question is related to php string-concatenation

The answer is


One step (IMHO) better

$result .= $personCount . ' people';

I think this code should work fine

while ($personCount < 10) {
$result = $personCount . "people ';
$personCount++;
}
// do not understand why do you need the (+) with the result.
echo $result;

This should be faster.

while ($personCount < 10) {
    $result .= "{$personCount} people ";
    $personCount++;
}

echo $result;

while ($personCount < 10) {
    $result .= ($personCount++)." people ";
}

echo $result;

$personCount=1;
while ($personCount < 10) {
    $result=0;
    $result.= $personCount . "person ";
    $personCount++;
    echo $result;
}