3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(object1,object2,object3); $attributes = array('first_name'=>'value','last_name'=>'value'); function filter_by_key($array, $attributes) { $filtered = array(); foreach($array as $k => $v) { //if($v->$member != $value) //stuck here $filtered[$k] = $v; } return $filtered; } var_dump(filter_by_key($array, $attributes));
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.6
Fatal error: Uncaught Error: Undefined constant "object1" in /in/eides:2 Stack trace: #0 {main} thrown in /in/eides on line 2
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant object1 - assumed 'object1' (this will throw an Error in a future version of PHP) in /in/eides on line 2 Warning: Use of undefined constant object2 - assumed 'object2' (this will throw an Error in a future version of PHP) in /in/eides on line 2 Warning: Use of undefined constant object3 - assumed 'object3' (this will throw an Error in a future version of PHP) in /in/eides on line 2 array(3) { [0]=> string(7) "object1" [1]=> string(7) "object2" [2]=> string(7) "object3" }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33
Notice: Use of undefined constant object1 - assumed 'object1' in /in/eides on line 2 Notice: Use of undefined constant object2 - assumed 'object2' in /in/eides on line 2 Notice: Use of undefined constant object3 - assumed 'object3' in /in/eides on line 2 array(3) { [0]=> string(7) "object1" [1]=> string(7) "object2" [2]=> string(7) "object3" }

preferences:
317.15 ms | 405 KiB | 417 Q