3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { static function cast(&$val, $key) { if (is_numeric($val)) { $val += 0; } } static function run() { $arr = ['stri33ng123', 84, 76.7, '45.6', '67.5e45', '56,9', 078]; var_dump($arr); //array_walk($arr , ['self', 'cast']); array_walk($arr , 'self::cast'); var_dump($arr); } } A::run(); //&& $val[0] != '0') {
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
array(7) { [0]=> string(11) "stri33ng123" [1]=> int(84) [2]=> float(76.7) [3]=> string(4) "45.6" [4]=> string(7) "67.5e45" [5]=> string(4) "56,9" [6]=> int(7) } array(7) { [0]=> string(11) "stri33ng123" [1]=> int(84) [2]=> float(76.7) [3]=> float(45.6) [4]=> float(6.75E+46) [5]=> string(4) "56,9" [6]=> int(7) }
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.27
Parse error: syntax error, unexpected '[' in /in/nk1RX on line 12
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/nk1RX on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/nk1RX on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/nk1RX on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/nk1RX on line 4
Process exited with code 255.

preferences:
256.45 ms | 1386 KiB | 198 Q