[PHP] Re: Putting a stop in a foreach - SOLVED

2004-05-09 Thread Verdon Vaillancourt
Hi Torsten, Aidan and Matt Both of Torsten's and Aidan's suggestions worked, though the number of returned results using Aidan's method isn't what I expected. This could be the result of something else and I'm trying to puzzle out why. Matt helped clarify my basic misunderstanding in what the fore

Re: [PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Torsten Roehr
"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > * Thus wrote Torsten Roehr ([EMAIL PROTECTED]): > > > > Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully > > correct) loop proposal: > > > > for ($i; $i < 5; $i++) { > > for($i=0; ...) > > I wouldn't s

Re: [PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Curt Zirzow
* Thus wrote Torsten Roehr ([EMAIL PROTECTED]): > > Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully > correct) loop proposal: > > for ($i; $i < 5; $i++) { for($i=0; ...) I wouldn't suggest this method, it is making the assumption that the indexes are numeric and sequenced

[PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Aidan Lister
Simple! $i = 0; foreach ($foos as $foo) { // do stuff $i++; if ($i > 5) break; } Cheers "Verdon Vaillancourt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi :) > > I'm trying to put a stop in a foreach statement following the user > suggestion here, php.net/manual/en

[PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Torsten Roehr
> > This is my attempt to count items and put a stop in the foreach so it only > > returns 5 items. > > > > foreach ($this->_content as $n => $item) { > > if ($n=="5") > > > break; > > } else > > > if ($this->_content[$n] => $item['type'] == 'item'){ > > $element

[PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Torsten Roehr
"Verdon Vaillancourt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi :) > > I'm trying to put a stop in a foreach statement following the user > suggestion here, php.net/manual/en/control-structures.foreach.php > > Not really knowing what I am doing, I am running into some synatx