3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 7.2.0 - 7.2.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" } } 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 5.6.0 - 5.6.30, 7.0.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
Output for hhvm-3.15.4
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: Invalid argument: function: not a valid callback array Warning: array_map(): Argument #2 should be an array or collection NULL