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
"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
* 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
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
> > 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
"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
6 matches
Mail list logo