Assuming the following code:
<?php
function doStuff($rowCount) {
$rowCount++;
echo $rowCount.' and ';
return $rowCount;
}
$rowCount = 1;
echo $rowCount.' and ';
doStuff($rowCount);
doStuff($rowCount);
doStuff($rowCount);
?>
The desired output is
1 and 2 and 3 and 4 and
The actual output is
1 and 2 and 2 and 2 and
I take it I'm musunderstanding how "return" works in this context. How could I best accomplish this?