For loop not showing the entire array [message #181847] |
Wed, 19 June 2013 14:34 |
Kevin Davis
Messages: 5 Registered: May 2012
Karma: 0
|
Junior Member |
|
|
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
|
|
|
Re: For loop not showing the entire array [message #181848 is a reply to message #181847] |
Wed, 19 June 2013 14:58 |
Kevin Davis
Messages: 5 Registered: May 2012
Karma: 0
|
Junior Member |
|
|
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
|
|
|
Re: For loop not showing the entire array [message #181849 is a reply to message #181848] |
Wed, 19 June 2013 20:05 |
bill
Messages: 310 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
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
>
|
|
|