php remove object from array by value code example
Example 1: php remove object from array
unset($array[$key]);
// You can do using function when no key
function unsetValue(array $array, $value, $strict = TRUE)
{
if(($key = array_search($value, $array, $strict)) !== FALSE) {
unset($array[$key]);
}
return $array;
}
Example 2: php remove object from array by property
$new_array = [];
foreach ($myarray as $key => $value) {
if ($value->catid == 29) {
$new_array[] = $value;
unset($myarray[$key]);
}
}