Lets say I have an array with some values, eg: $category="Wedding"; $cats=array( 'wedding-cakes'=>array('main', 'Wedding Cakes'), 'wedding-venues'=>array('main', 'Wedding Venues'), 'other-cakes=>array('sub', 'Other Cakes'), 'other-venues'=>array('sub', 'Other Venues'), ); Code (markup): Now when I output this array, if it finds the value of $category in $cats[1], it does not print out that bit, eg in the above the two 'Wedding' entries should only output 'Cakes' and 'Venues' respectively as $cats[1] contains the string "Wedding".
str_replace() lets you provide an array as the replace subject too and will return the new array. $new_cats = str_replace($category, "", $cats);