且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP搜索数组中的数组

更新时间:2023-01-16 20:32:45

foreach吗?

function searchMyCoolArray($arrays, $key, $search) {
   $count = 0;

   foreach($arrays as $object) {
       if(is_object($object)) {
          $object = get_object_vars($object);
       }

       if(array_key_exists($key, $object) && $object[$key] == $search) $count++;
   }

   return $count;
}

echo searchMyCoolArray($input, 'info_type_id', 4);