php array using in_array not working -
hi have object array ($perms_found) follow:
array ( [0] => stdclass object ( [permissions_id] => 1 ) [1] => stdclass object ( [permissions_id] => 2 ) [2] => stdclass object ( [permissions_id] => 3 ) )
i want use in_array find of permissions_id , have tried this:
var_dump(in_array(1, $perms_found , true));
but keep getting :
bool(false)
what doing wrong please help?
in_array
looking 1
in array, array contains objects, not numbers. use loop accesses object properties:
$found = false; foreach ($perms_found $perm) { if ($perm->permissions_id == 1) { $found = true; break; } }
Comments
Post a Comment