Possible Duplicate:
How to delete an element from an array in php?
I have a list of things, cars for instance
$cars[0] = "audi";
$cars[1] = "saab";
$cars[2] = "volvo";
$cars[3] = "vw";
How do i delete "volvo" from the list?
Possible Duplicate:
How to delete an element from an array in php?
I have a list of things, cars for instance
$cars[0] = "audi";
$cars[1] = "saab";
$cars[2] = "volvo";
$cars[3] = "vw";
How do i delete "volvo" from the list?
$volvoIndex = array_search('volvo', $cars);
unset($cars[$volvoIndex]);
you can do with unset
unset($cars[2]);
But after that you need to iterate array with foreach
$cars = array_filter($cars) it will remove the empty array items as well. :)