3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '1-350,9-390.99'; $array = explode(',',$string); $new_array = array(); array_walk($array,'walk', &$new_array); function walk($val, $key, $new_array){ $nums = explode('-',$val); $new_array[$nums[0]] = $nums[1]; } print_r($new_array);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.28, 8.3.0 - 8.3.17, 8.4.1 - 8.4.4
Parse error: syntax error, unexpected token "&", expecting ")" in /in/4oFZh on line 7
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Parse error: syntax error, unexpected '&', expecting ')' in /in/4oFZh on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34
Parse error: syntax error, unexpected '&' in /in/4oFZh on line 7
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Fatal error: Call-time pass-by-reference has been removed in /in/4oFZh on line 7
Process exited with code 255.

preferences:
196.21 ms | 999 KiB | 7 Q