PHP: pass a variable to a function, do something to the variable, return it back

pcyigr7sur

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