Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
Last active January 1, 2016 07:59
Show Gist options
  • Select an option

  • Save aoeuidht/8115186 to your computer and use it in GitHub Desktop.

Select an option

Save aoeuidht/8115186 to your computer and use it in GitHub Desktop.
human couldn't understood php.
<?php
function test_foreach(&$tgt)
{
foreach ($tgt as &$_t)
{
$_t['v'] = $_t['v'] + 1;
}
foreach ($tgt as $_t)
{
echo $_t['v'] . "\n";
}
}
$tgt = array();
for ($i=0; $i<5; $i++)
{
$tgt[] = array('v' => $i);
}
test_foreach($tgt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment