I'm learning PHP for loop and this is a problem I couldn't quite understand. Could anyone please help me to explain the difference in the results of these two codes?
<?php
for ($i=0; $i<10;$i++) // the result is 02468
{echo $i++;}
?>
<?php
for ($i=0; $i<10;$i++) // the result is 13579
{echo ++$i;}
?>
I know the difference here lies in $i++ (post-increment) and ++$i (pre-increment). However, I couldn't figure out the process that PHP works to give out the results. Can anyone help me with these? Thank you very much.