below is an output of my laravel object...
$my_array = Array( [0] => stdClass Object ( [From] => name1 [To] => name12 [Message] => hey) [1] => stdClass Object ( [From] => name13 [To] => name143 [Message] => byeeeeee)
I need to find name12
is present or not without using foreach loop
... how do i do this???I have tried...
if (in_array('name12', $my_array)) {
echo "Match found";
}
else {
echo "Match not found";
}
Anyway to fix this?
if count(
array_filter(
$my_array,
function($value) {
return $value->From == 'name12';
}
) > 0) {
echo "Match found";
} else {
echo "Match not found";
}