Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #9798 > unrolled thread

For loop not showing the entire array

Started byKevin Davis <kevindavis338@gmail.com>
First post2013-06-19 07:34 -0700
Last post2013-06-19 16:05 -0400
Articles 3 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  For loop not showing the entire array Kevin Davis <kevindavis338@gmail.com> - 2013-06-19 07:34 -0700
    Re: For loop not showing the entire array Kevin Davis <kevindavis338@gmail.com> - 2013-06-19 07:58 -0700
      Re: For loop not showing the entire array Twayne <nobody@spamcop.net> - 2013-06-19 16:05 -0400

#9798 — For loop not showing the entire array

FromKevin Davis <kevindavis338@gmail.com>
Date2013-06-19 07:34 -0700
SubjectFor loop not showing the entire array
Message-ID<ab435d0b-6f11-4859-9c25-45d9d24acff7@googlegroups.com>
Hi there,

I'm stuck on something which I know could be simple..

If you look at the following array:

$data = json_decode($result, TRUE);

then I have a counter:

 $i = 0;

then of course a loop:

foreach ($data as $temp)
 {
    $userId = $data['data']['items'][$i]['id'];    
    echo $userId . "<BR>";
    $i++;
 }

The problem is that the loop is only going through the first 2 records and there is more than 2... Is there a reason why?

Thank you,
Kevin

[toc] | [next] | [standalone]


#9799

FromKevin Davis <kevindavis338@gmail.com>
Date2013-06-19 07:58 -0700
Message-ID<7f2930ca-78c6-4377-85ee-d1768a67e96b@googlegroups.com>
In reply to#9798
Never mind,I found the solution myself. 

On Wednesday, June 19, 2013 9:34:59 AM UTC-5, Kevin Davis wrote:
> Hi there,
> 
> 
> 
> I'm stuck on something which I know could be simple..
> 
> 
> 
> If you look at the following array:
> 
> 
> 
> $data = json_decode($result, TRUE);
> 
> 
> 
> then I have a counter:
> 
> 
> 
>  $i = 0;
> 
> 
> 
> then of course a loop:
> 
> 
> 
> foreach ($data as $temp)
> 
>  {
> 
>     $userId = $data['data']['items'][$i]['id'];    
> 
>     echo $userId . "<BR>";
> 
>     $i++;
> 
>  }
> 
> 
> 
> The problem is that the loop is only going through the first 2 records and there is more than 2... Is there a reason why?
> 
> 
> 
> Thank you,
> 
> Kevin

[toc] | [prev] | [next] | [standalone]


#9800

FromTwayne <nobody@spamcop.net>
Date2013-06-19 16:05 -0400
Message-ID<kpt2tm$89h$1@speranza.aioe.org>
In reply to#9799
Care to enlighten the rest of us what the solution was?

Twayne`



On 2013-06-19 10:58 AM, Kevin Davis wrote:
> Never mind,I found the solution myself.
>
> On Wednesday, June 19, 2013 9:34:59 AM UTC-5, Kevin Davis wrote:
>> Hi there,
>>
>>
>>
>> I'm stuck on something which I know could be simple..
>>
>>
>>
>> If you look at the following array:
>>
>>
>>
>> $data = json_decode($result, TRUE);
>>
>>
>>
>> then I have a counter:
>>
>>
>>
>>   $i = 0;
>>
>>
>>
>> then of course a loop:
>>
>>
>>
>> foreach ($data as $temp)
>>
>>   {
>>
>>      $userId = $data['data']['items'][$i]['id'];
>>
>>      echo $userId . "<BR>";
>>
>>      $i++;
>>
>>   }
>>
>>
>>
>> The problem is that the loop is only going through the first 2 records and there is more than 2... Is there a reason why?
>>
>>
>>
>> Thank you,
>>
>> Kevin
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web