3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 7.2.0 - 7.2.6
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 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.1.20
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" }