Delete element from multidimensional-array based on value

Try this:

function removeElementWithValue($array, $key, $value){
     foreach($array as $subKey => $subArray){
          if($subArray[$key] == $value){
               unset($array[$subKey]);
          }
     }
     return $array;
}

Then you would call it like this:

$array = removeElementWithValue($array, "year", 2011);

Leave a Comment