Most efficient way to search for object in an array by a specific property’s value
You can iterate that objects: function findObjectById($id){ $array = array( /* your array of objects */ ); foreach ( $array as $element ) { if ( $id == $element->id ) { return $element; } } return false; } Edit: Faster way is to have an array with keys equals to objects’ ids (if unique); Then … Read more