Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old June 8th, 2006, 01:15 PM
RalphLacle@gmail.com
Guest
 
Posts: n/a
Default Nested Arrays

Hi,

I hope somebody can explain this to me.

I have a nested array:

Array
(
[AiHist_SelectResult] => Array
(
[clsASCAiHist] => Array
(
[0] => Array
(
[HistID] => 0
[AiID] => 0
[TimestampUTC] => Array
(
[IsNull] => false
[Value] => 632851929000000000
)

[AiValue] => 17.2
)

I only want to print the AiValue

How can i do that?

  #2  
Old June 8th, 2006, 01:25 PM
Alan Little
Guest
 
Posts: n/a
Default Re: Nested Arrays

Carved in mystic runes upon the very living rock, the last words of
<RalphLacle@gmail.com> of comp.lang.php make plain:
[color=blue]
> I have a nested array:
>
> Array
> (
> [AiHist_SelectResult] => Array
> (
> [clsASCAiHist] => Array
> (
> [0] => Array
> (
> [HistID] => 0
> [AiID] => 0
> [TimestampUTC] => Array
> (
> [IsNull] => false
> [Value] => 632851929000000000
> )
>
> [AiValue] => 17.2
> )
>
> I only want to print the AiValue
>
> How can i do that?[/color]

print $Array['AiHist_SelectResult']['clsASCAiHist'][0]['AiValue'];

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
  #3  
Old June 8th, 2006, 01:25 PM
Henrik Hansen
Guest
 
Posts: n/a
Default Re: Nested Arrays

RalphLacle@gmail.com writes:
[color=blue]
> Hi,
>
> I hope somebody can explain this to me.
>
> I have a nested array:
>
> Array
> (
> [AiHist_SelectResult] => Array
> (
> [clsASCAiHist] => Array
> (
> [0] => Array
> (
> [HistID] => 0
> [AiID] => 0
> [TimestampUTC] => Array
> (
> [IsNull] => false
> [Value] => 632851929000000000
> )
>
> [AiValue] => 17.2
> )
>
> I only want to print the AiValue
>
> How can i do that?[/color]

foreach ($your_array_name["AiHist_SelectResult"]["clsASCAiHist"] as $key => $value) {
echo $value["AiValue"];
}

--
Henrik Hansen
  #4  
Old June 8th, 2006, 01:25 PM
Paul Lautman
Guest
 
Posts: n/a
Default Re: Nested Arrays

RalphLacle@gmail.com wrote:[color=blue]
> Hi,
>
> I hope somebody can explain this to me.
>
> I have a nested array:
>
> Array
> (
> [AiHist_SelectResult] => Array
> (
> [clsASCAiHist] => Array
> (
> [0] => Array
> (
> [HistID] => 0
> [AiID] => 0
> [TimestampUTC] => Array
> (
> [IsNull] => false
> [Value] => 632851929000000000
> )
>
> [AiValue] => 17.2
> )
>
> I only want to print the AiValue
>
> How can i do that?[/color]

Alan beat me to your answer. If you have a question like this again, posting
the output from var_export rather than print_r will mean that we can test
our answer to you quickly.


  #5  
Old June 8th, 2006, 01:35 PM
Henrik Hansen
Guest
 
Posts: n/a
Default Re: Nested Arrays

Alan Little <alan@n-o-s-p-a-m-phorm.com> writes:
[color=blue]
> Carved in mystic runes upon the very living rock, the last words of
> <RalphLacle@gmail.com> of comp.lang.php make plain:
>[color=green]
>> I have a nested array:
>>
>> Array
>> (
>> [AiHist_SelectResult] => Array
>> (
>> [clsASCAiHist] => Array
>> (
>> [0] => Array
>> (
>> [HistID] => 0
>> [AiID] => 0
>> [TimestampUTC] => Array
>> (
>> [IsNull] => false
>> [Value] => 632851929000000000
>> )
>>
>> [AiValue] => 17.2
>> )
>>
>> I only want to print the AiValue
>>
>> How can i do that?[/color]
>
> print $Array['AiHist_SelectResult']['clsASCAiHist'][0]['AiValue'];[/color]

Oh right, I asumed you were getting more than one value in the array,
if not use this instead of what I wrote in my post :)

--
Henrik Hansen
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.