Page 1 of 1

remove an item from inside an array

Posted: Tue Dec 16, 2003 1:05 pm
by kkawamoto
I'm new to PHP and am working on a shopping cart that I'm doing for my final project and we are instructed to do this using arrays. We are use array_push to put the item we are adding at the end of the array which I already have done but the problem I'm running into is removing the cart item from the array. Following the instructions I have to remove an item from an array: how do I change the value of the item I wish to delete within the array to "z" so I can use array_pop to remove it? Any advice would be helpful.

Posted: Tue Dec 16, 2003 1:14 pm
by scorphus
I hope [php_man]array_filter[/php_man]() can help you on this matter.

Cheers,
Scorphus.

Posted: Tue Dec 16, 2003 1:19 pm
by Draco_03
You might also take a look at
array_splice()

ps : php manual is very helpful : http://ca.php.net/manual/en/function.array-splice.php

Posted: Tue Dec 16, 2003 3:33 pm
by dull1554
wow over my head a bit

Posted: Wed Dec 17, 2003 2:22 am
by twigletmac
You can use the index of the element and just [php_man]unset[/php_man]() it.

Mac