3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = range(3, 9); foreach ($a as $b) { switch($b) { case 3: $b = 7; case 7: $b = 3; default: // do nothing } } echo implode('-', $a) . PHP_EOL; $a = range(3, 9); foreach ($a as $key => $b) { switch($b) { case 3: $a[$key] = 7; case 7: $a[$key] = 3; default: // do nothing } } echo implode('-', $a) . PHP_EOL; $a = range(3, 9); foreach ($a as &$b) { switch($b) { case 3: $b = 7; case 7: $b = 3; default: // do nothing } } echo implode('-', $a) . PHP_EOL;
based on DddcB
Output for 5.3.21 - 7.0.4, 7.0.6 - 7.2.0
3-4-5-6-7-8-9 3-4-5-6-3-8-9 3-4-5-6-3-8-9
Output for 7.0.5
3-4-5-6-7-8-9 3-4-5-6-3-8-9 3-4-5-6-7-8-9