Nested Arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RalphLacle@gmail.com

    Nested Arrays

    Hi,

    I hope somebody can explain this to me.

    I have a nested array:

    Array
    (
    [AiHist_SelectRe sult] => Array
    (
    [clsASCAiHist] => Array
    (
    [0] => Array
    (
    [HistID] => 0
    [AiID] => 0
    [TimestampUTC] => Array
    (
    [IsNull] => false
    [Value] => 632851929000000 000
    )

    [AiValue] => 17.2
    )

    I only want to print the AiValue

    How can i do that?

  • Alan Little

    #2
    Re: Nested Arrays

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

    print $Array['AiHist_SelectR esult']['clsASCAiHist'][0]['AiValue'];

    --
    Alan Little
    Phorm PHP Form Processor

    Comment

    • Henrik Hansen

      #3
      Re: Nested Arrays

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

      foreach ($your_array_na me["AiHist_SelectR esult"]["clsASCAiHi st"] as $key => $value) {
      echo $value["AiValue"];
      }

      --
      Henrik Hansen

      Comment

      • Paul Lautman

        #4
        Re: Nested Arrays

        RalphLacle@gmai l.com wrote:[color=blue]
        > Hi,
        >
        > I hope somebody can explain this to me.
        >
        > I have a nested array:
        >
        > Array
        > (
        > [AiHist_SelectRe sult] => Array
        > (
        > [clsASCAiHist] => Array
        > (
        > [0] => Array
        > (
        > [HistID] => 0
        > [AiID] => 0
        > [TimestampUTC] => Array
        > (
        > [IsNull] => false
        > [Value] => 632851929000000 000
        > )
        >
        > [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.


        Comment

        • Henrik Hansen

          #5
          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@gma il.com> of comp.lang.php make plain:
          >[color=green]
          >> I have a nested array:
          >>
          >> Array
          >> (
          >> [AiHist_SelectRe sult] => Array
          >> (
          >> [clsASCAiHist] => Array
          >> (
          >> [0] => Array
          >> (
          >> [HistID] => 0
          >> [AiID] => 0
          >> [TimestampUTC] => Array
          >> (
          >> [IsNull] => false
          >> [Value] => 632851929000000 000
          >> )
          >>
          >> [AiValue] => 17.2
          >> )
          >>
          >> I only want to print the AiValue
          >>
          >> How can i do that?[/color]
          >
          > print $Array['AiHist_SelectR esult']['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

          Comment

          Working...