3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { static function cast(&$val, $key) { if (is_numeric($val) && $val[0] != '0') { $val += 0; } } static function run() { $arr = ['stri33ng123', 84, 76.7, '45.6', '67.5e45', '56,9', '078', 07.8, '.9']; var_dump($arr); //array_walk($arr , ['self', 'cast']); array_walk($arr , 'self::cast'); var_dump($arr); } } A::run();
Output for 8.3.0 - 8.3.6
array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> string(2) ".9" } Deprecated: Use of "self" in callables is deprecated in /in/PgaQA on line 15 Warning: Trying to access array offset on int in /in/PgaQA on line 4 Warning: Trying to access array offset on float in /in/PgaQA on line 4 Warning: Trying to access array offset on float in /in/PgaQA on line 4 array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> float(0.9) }
Output for 8.2.0 - 8.2.18
array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> string(2) ".9" } Deprecated: Use of "self" in callables is deprecated in /in/PgaQA on line 15 Warning: Trying to access array offset on value of type int in /in/PgaQA on line 4 Warning: Trying to access array offset on value of type float in /in/PgaQA on line 4 Warning: Trying to access array offset on value of type float in /in/PgaQA on line 4 array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> float(0.9) }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27
array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> string(2) ".9" } Warning: Trying to access array offset on value of type int in /in/PgaQA on line 4 Warning: Trying to access array offset on value of type float in /in/PgaQA on line 4 Warning: Trying to access array offset on value of type float in /in/PgaQA on line 4 array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> float(0.9) }
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> string(2) ".9" } Notice: Trying to access array offset on value of type int in /in/PgaQA on line 4 Notice: Trying to access array offset on value of type float in /in/PgaQA on line 4 Notice: Trying to access array offset on value of type float in /in/PgaQA on line 4 array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> float(0.9) }
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.26
array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> string(2) ".9" } array(9) { [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]=> string(3) "078" [7]=> float(7.8) [8]=> float(0.9) }
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/PgaQA on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/PgaQA on line 11
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/PgaQA on line 3
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/PgaQA on line 3
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/PgaQA on line 3
Process exited with code 255.

preferences:
266.97 ms | 401 KiB | 382 Q