Removing specific array items
- From: Scott Johnson <noonehome@xxxxxxxxxxxxxxxxx>
- Date: Thu, 03 May 2012 06:25:09 -0700
In a simple quote cart I track items in a session.
$_SESSION['quote'][##] = {data}
Which increments the ## for each added item.
At the time when the client wants to remove an item from the cart I just clear the {data} from $_SESSION['quote'][item_id] = '';
The issue i run into is when I want to display the cart, i just cant step thru the array without seeing if a particular item is '', which works but would like to find a more 'elegant' way.
With all that said, is there a way to remove the item from the array rather then clear the items data.
I can only think to
1. 'somehow' move or rotate the item to the end of the array and POP it off
2. or even go as far as step thru the array and create a new one with only populated data items.
I have looked thru the 50+ different array functions and can't seem to find the right tool. Maybe a combination I am not seeing.
Thanks
Scotty
.
- Follow-Ups:
- Re: Removing specific array items
- From: Thomas 'PointedEars' Lahn
- Re: Removing specific array items
- From: M. Strobel
- Re: Removing specific array items
- From: Jerry Stuckle
- Re: Removing specific array items
- Prev by Date: Re: Session variables..
- Next by Date: Re: Removing specific array items
- Previous by thread: Re: Session variables..
- Next by thread: Re: Removing specific array items
- Index(es):
Relevant Pages
|