FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Removing specific array items
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Removing specific array items [message #177969] Thu, 03 May 2012 13:25 Go to previous message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma:
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Session variables..
Next Topic: Re: reading a newline from a properties file
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 21:13:15 GMT 2024

Total time taken to generate the page: 0.04010 seconds