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
Re: Removing specific array items [message #177970 is a reply to message #177969] Thu, 03 May 2012 14:55 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 5/3/2012 9:25 AM, Scott Johnson wrote:
> 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

unset().

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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: Mon Dec 02 01:22:31 GMT 2024

Total time taken to generate the page: 0.03899 seconds