Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5810

Re: Removing specific array items

From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: Removing specific array items
Date 2012-05-03 17:20 +0200
Message-ID <a0fm2eFu5sU1@mid.uni-berlin.de> (permalink)
References <jnu10f$v35$1@dont-email.me>

Show all headers | View raw


Am 03.05.2012 15:25, schrieb Scott Johnson:
> 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.

unset($_SESSION['quote'][item_id]);

/Str.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Removing specific array items Scott Johnson <noonehome@chalupasworld.com> - 2012-05-03 06:25 -0700
  Re: Removing specific array items Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-03 10:55 -0400
    Re: Removing specific array items Scott Johnson <noonehome@chalupasworld.com> - 2012-05-03 16:32 -0700
  Re: Removing specific array items "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-05-03 17:20 +0200
  Re: Removing specific array items Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-03 18:05 +0200

csiph-web