Answers for "how to search in array and return only one value php"

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
0

array value search in php

function searchForId($id, $array) {
   foreach ($array as $key => $val) {
       if ($val['uid'] === $id) {
           return $key;
       }
   }
   return null;
}
Posted by: Guest on November-04-2021

Code answers related to "how to search in array and return only one value php"

Browse Popular Code Answers by Language