Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!not-for-mail From: "M. Strobel" Newsgroups: comp.lang.php Subject: Re: Removing specific array items Date: Thu, 03 May 2012 17:20:46 +0200 Lines: 20 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de mT8PblMwTtvu+6goNMr4ww3x2ZAyP8dQu0ul/xuj1XW2LoPy8rpG8RSxrVd1rMjFE= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20 In-Reply-To: Xref: csiph.com comp.lang.php:5810 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.