Check whether an array is empty

function in_multi_dimensional_array($multidimarray, $multidimarray_key, $lookingfor ) {
 $found = false;
 foreach ($multidimarray as $key => $data) {
  if ($data[$multidimarray_key] == $lookingfor) {
   // item found => add new keys & data if (!empty($multidimarray_newdata))
   $found = true;
   break; // no need to loop anymore, as we have found the item => exit the loop
  }
 }
 return $found;
}

function in_multi_dimensional_modifiable_array($multidimarray, $multidimarray_key, $lookingfor, $multidimarray_newdata = array() ) {
 $found = false;
 foreach ($multidimarray as $key => $data) {
  if ($data[$multidimarray_key] == $lookingfor) {
   // item found => add new keys & data if (!empty($multidimarray_newdata))
   foreach($multidimarray_newdata as $key => $value) {
    $data[$key] = $value;
   }
   $found = true;
   break; // no need to loop anymore, as we have found the item => exit the loop
  }
 }
 return $found;

// if ($found === false) {
 // The id you were looking for has not been found,
 // which means the corresponding item is not already present in your array
 // => Add a new item to the array
// }
}

Source: Check whether an array is empty