3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function hash2($n) { for ($i = 0; $i < $n; $i++) { $hash1["foo_$i"] = $i; $hash2["foo_$i"] = 0; } for ($i = $n; $i > 0; $i--) { foreach($hash1 as $key => $value) { $hash2[$key] += $value; } } $first = "foo_0"; $last = "foo_".($n-1); print "{$hash1[$first]} {$hash1[$last]} {$hash2[$first]} {$hash2[$last]}\n"; } hash2(1000);
Output for 4.3.0 - 7.1.0
0 999 0 999000