3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = "hello : 6\ngoodbye : 7\nfoo : bar\n"; $lines = explode("\n", trim($data)) $tuples = array_map( function($line) { return array_map('trim', explode(':', $line)); }, $lines ); $output = array_combine( array_map(function($t) { return $t[0]; }, $tuples), array_map(function($t) { return $t[1]; }, $tuples) ); var_dump($output);
Output for 5.4.0 - 5.4.19
Parse error: syntax error, unexpected '$tuples' (T_VARIABLE) in /in/ZFDvl on line 7
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE in /in/ZFDvl on line 7
Process exited with code 255.

preferences:
173.71 ms | 1395 KiB | 55 Q