In the following example:
foreach ($results as $key = $item) {
//bla bla bla -- unset some of the $items
}
I want to modify $results within the foreach. In other words,
during a given pass of this iteration, I want to delete some
of the items based on particular conditions. Then on the
foreach ($results as $key = $item)
{
if ($item == 'foo') unset($results[$key]);
}
-Original Message-
From: Andres Gonzalez [mailto:and...@packetstorm.com]
Sent: Tuesday, June 23, 2009 11:27 AM
To: php-general@lists.php.net
Subject: [PHP] modifying within foreach
-
From: Andres Gonzalez [mailto:and...@packetstorm.com]
Sent: Tuesday, June 23, 2009 11:27 AM
To: php-general@lists.php.net
Subject: [PHP] modifying within foreach
In the following example:
foreach ($results as $key = $item) {
//bla bla bla -- unset some of the $items
}
I want
Andres Gonzalez and...@packetstorm.com wrote on 06/23/2009 12:26:38 PM:
I want to modify $results within the foreach. In other words,
during a given pass of this iteration, I want to delete some
of the items based on particular conditions. Then on the next
pass thru the foreach, I want
On Tue, 2009-06-23 at 12:56 -0600, kirk.john...@zootweb.com wrote:
Andres Gonzalez and...@packetstorm.com wrote on 06/23/2009 12:26:38 PM:
I want to modify $results within the foreach. In other words,
during a given pass of this iteration, I want to delete some
of the items based on
://daevid.com
-Original Message-
From: Andres Gonzalez [mailto:and...@packetstorm.com]
Sent: Tuesday, June 23, 2009 11:45 AM
Cc: php-general@lists.php.net
Subject: Re: [PHP] modifying within foreach
I do not want to delete the whole array, only a particular $item.
given this $results array
Thanks guys--passing by reference solved my problem. I was not aware
that the foreach statement works on a copy. This was explained in the
online documentation. Duh!!
Thanks again,
-Andres
Ashley Sheridan wrote:
On Tue, 2009-06-23 at 12:56 -0600, kirk.john...@zootweb.com wrote:
On Tue, 2009-06-23 at 15:07 -0400, Eddie Drapkin wrote:
It's just foreach($foo as $key = $item) { }
You can't assign the key by reference .
On Tue, Jun 23, 2009 at 3:04 PM, Ashley
Sheridana...@ashleysheridan.co.uk wrote:
On Tue, 2009-06-23 at 12:56 -0600, kirk.john...@zootweb.com wrote:
Ashley Sheridan wrote:
On Tue, 2009-06-23 at 15:07 -0400, Eddie Drapkin wrote:
It's just foreach($foo as $key = $item) { }
You can't assign the key by reference .
On Tue, Jun 23, 2009 at 3:04 PM, Ashley
Sheridana...@ashleysheridan.co.uk wrote:
On Tue, 2009-06-23 at 12:56 -0600,
It's just foreach($foo as $key = $item) { }
You can't assign the key by reference .
On Tue, Jun 23, 2009 at 3:04 PM, Ashley
Sheridana...@ashleysheridan.co.uk wrote:
On Tue, 2009-06-23 at 12:56 -0600, kirk.john...@zootweb.com wrote:
Andres Gonzalez and...@packetstorm.com wrote on 06/23/2009
AddBrainHandler x-httpd-php5 .php
On Tue, Jun 23, 2009 at 4:25 PM, Robert Cummings rob...@interjinn.comwrote:
Ashley Sheridan wrote:
On Tue, 2009-06-23 at 15:07 -0400, Eddie Drapkin wrote:
It's just foreach($foo as $key = $item) { }
You can't assign the key by reference .
On Tue, Jun
11 matches
Mail list logo