fixed it some other way.
$item is the list of items
$food is what food to remove from the list
- $line is the array line the food is on
$line = array_search($food,$item);
$item[$line] = $item[$totallines - 1];
$thisnamedosentmatter = array_pop ($item);
if your searching for carrots, this will turn:
pie
candy
carrots
prunes
oranges
into:
pie
candy
oranges
prunes
(it replaces carrots with oranges, the last food on the list).
hope this is of future use to someone.