3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'foobar: 2008'; if (preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches)) { print_r( array_filter($matches, function ($key) { return !is_int($key); }, ARRAY_FILTER_USE_KEY) ); }
Output for 7.1.17 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Array ( [name] => foobar [digit] => 2008 )
Output for 5.4.9
Notice: Use of undefined constant ARRAY_FILTER_USE_KEY - assumed 'ARRAY_FILTER_USE_KEY' in /in/icrJ0 on line 6 Warning: array_filter() expects at most 2 parameters, 3 given in /in/icrJ0 on line 6
Output for 4.4.8
Parse error: syntax error, unexpected T_FUNCTION in /in/icrJ0 on line 6
Process exited with code 255.
Output for 4.3.7
Parse error: parse error, unexpected T_FUNCTION in /in/icrJ0 on line 6
Process exited with code 255.

preferences:
138.24 ms | 409 KiB | 5 Q