Hey all:
Let's say I have the code:
foreach($data as $row)
{
do something with each $row
}
Is there a way to do something specific to the first item iterated?
Pseudocode:
foreach($data as $row)
{
if first time through iteration do something with $row
else do something which each remaining $row
}
Is this possible? I think I could use a regular 'for' loop, using the
length of the $data array as a guide, and then an 'if..else' structure
to see if it is the first time through the 'for' loop, but I was
looking for a more elegant solution.
-CJL
Let's say I have the code:
foreach($data as $row)
{
do something with each $row
}
Is there a way to do something specific to the first item iterated?
Pseudocode:
foreach($data as $row)
{
if first time through iteration do something with $row
else do something which each remaining $row
}
Is this possible? I think I could use a regular 'for' loop, using the
length of the $data array as a guide, and then an 'if..else' structure
to see if it is the first time through the 'for' loop, but I was
looking for a more elegant solution.
-CJL
Comment