Re: foreach problem part two [message #184538 is a reply to message #184536] |
Tue, 07 January 2014 09:07 |
Christoph Michael Bec
Messages: 207 Registered: June 2013
Karma:
|
Senior Member |
|
|
John Smith wrote:
> On Fri, 20 Dec 2013 02:09:46 +0100, Christoph Michael Becker
> <cmbecker69(at)arcor(dot)de> wrote:
>
>> Assume, you have an array:
>>
>> $array = array('one', 'two', 'three');
>>
>> Now you want to echo its elements in order. What is simpler and more
>> readable?
>>
>> $i = 0;
>> while ($i < count($array)) {
>> echo $array[$i];
>> }
>
> At the first example you don't have to increment the $i?
Oops! Of course you'd have to:
$i = 0;
while ($i < count($array)) {
echo $array[$i];
$i++;
}
--
Christoph M. Becker
|
|
|