Answers for "php in array object search"

PHP
12

php search on array

//array_search
$result = array_search("apple", $fruit_array); // return index or false

//in_array
$result = in_array("apple", $fruit_array); // return true or false
Posted by: Guest on July-05-2021
1

search string inside array of objects php

$item = null;
foreach($array as $struct) {
    if ($v == $struct->ID) {
        $item = $struct;
        break;
    }
}
Posted by: Guest on November-24-2021

Browse Popular Code Answers by Language