3v4l.org

run code in 300+ PHP versions simultaneously
<?php $o = new stdClass; $o->text = "ans1"; $o2 = new stdClass; $o2->text = "ans2"; $o3 = new stdClass; $o3->text = "ans3"; $arr = [$o, $o2, $o3]; var_dump($arr); $nu = array_map($arr,callback); function callback($e) { return $e->text; } var_dump($nu);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
array(3) { [0]=> object(stdClass)#1 (1) { ["text"]=> string(4) "ans1" } [1]=> object(stdClass)#2 (1) { ["text"]=> string(4) "ans2" } [2]=> object(stdClass)#3 (1) { ["text"]=> string(4) "ans3" } } Fatal error: Uncaught Error: Undefined constant "callback" in /in/S8KDF:16 Stack trace: #0 {main} thrown in /in/S8KDF on line 16
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array(3) { [0]=> object(stdClass)#1 (1) { ["text"]=> string(4) "ans1" } [1]=> object(stdClass)#2 (1) { ["text"]=> string(4) "ans2" } [2]=> object(stdClass)#3 (1) { ["text"]=> string(4) "ans3" } } Fatal error: Uncaught Error: Undefined constant "callback" in /in/S8KDF:16 Stack trace: #0 {main} thrown in /in/S8KDF on line 16
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
array(3) { [0]=> object(stdClass)#1 (1) { ["text"]=> string(4) "ans1" } [1]=> object(stdClass)#2 (1) { ["text"]=> string(4) "ans2" } [2]=> object(stdClass)#3 (1) { ["text"]=> string(4) "ans3" } } Warning: Use of undefined constant callback - assumed 'callback' (this will throw an Error in a future version of PHP) in /in/S8KDF on line 16 Warning: array_map() expects parameter 1 to be a valid callback, array must have exactly two members in /in/S8KDF on line 16 NULL
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
array(3) { [0]=> object(stdClass)#1 (1) { ["text"]=> string(4) "ans1" } [1]=> object(stdClass)#2 (1) { ["text"]=> string(4) "ans2" } [2]=> object(stdClass)#3 (1) { ["text"]=> string(4) "ans3" } } Notice: Use of undefined constant callback - assumed 'callback' in /in/S8KDF on line 16 Warning: array_map() expects parameter 1 to be a valid callback, array must have exactly two members in /in/S8KDF on line 16 NULL

preferences:
160.29 ms | 403 KiB | 173 Q