3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( 'users' => 1, 'groups' => array( 'users' => 5, 'groups' => array( 'users' => 3 ) ), 'groups' => array( 'users' => 6 ) ); function calcTotal($array) { foreach($array['groups'] as &$group) { echo $array['users']; var_dump($group); calcTotal($group); } } calcTotal($array);
Output for 5.0.0 - 7.1.0
1int(6) Warning: Cannot use a scalar value as an array in /in/ldSJ6 on line 17 Warning: Invalid argument supplied for foreach() in /in/ldSJ6 on line 17
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/ldSJ6 on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/ldSJ6 on line 17
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/ldSJ6 on line 17
Process exited with code 255.