Skip to content

Instantly share code, notes, and snippets.

@jt2k
Last active December 31, 2015 09:09
Show Gist options
  • Save jt2k/7964626 to your computer and use it in GitHub Desktop.
Save jt2k/7964626 to your computer and use it in GitHub Desktop.
Can someone explain this to me?
<?php
$array = array(0,1,2,3);
foreach ($array as &$val) {
$val = $val + 1;
}
print_r($array);
foreach ($array as $foo) {
echo $foo;
}
echo "\n";
foreach ($array as $val) {
echo $val;
}
echo "\n";
/* Output:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
1234
1233
^ ?????
*/
@jt2k
Copy link
Author

jt2k commented Dec 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment