2016-03-29 8 views
-3

wirklich brauchen Ihre Hilfe bei diesem Array:Array-Php-Schleife. Schwierige Anordnung. Machen Sie eine Schleife

Array 
(
    [status] => 200 
    [error] => 
    [resource] => Array 
     (
      [type] => stats 
      [data] => Array 
       (
        [0] => Array 
         (
          [date] => Array 
           (
            [year] => 2015 
            [month] => 12 
           ) 

          [currency] => USD 
          [stats] => Array 
           (
            [count] => 2 
            [total] => 2.53 
            [average] => 1.265 
           ) 

         ) 

        [1] => Array 
         (
          [date] => Array 
           (
            [year] => 2016 
            [month] => 1 
           ) 

          [currency] => USD 
          [stats] => Array 
           (
            [count] => 2 
            [total] => 15 
            [average] => 7.5 
           ) 

         ) 

        [2] => Array 
         (
          [date] => Array 
           (
            [year] => 2016 
            [month] => 1 
           ) 

          [currency] => AUD 
          [stats] => Array 
           (
            [count] => 1 
            [total] => 15 
            [average] => 15 
           ) 

         ) 

        [3] => Array 
         (
          [date] => Array 
           (
            [year] => 2016 
            [month] => 2 
           ) 

          [currency] => AUD 
          [stats] => Array 
           (
            [count] => 7 
            [total] => 1419.02 
            [average] => 202.71714285714 
           ) 

         ) 

        [4] => Array 
         (
          [date] => Array 
           (
            [year] => 2016 
            [month] => 2 
           ) 

          [currency] => USD 
          [stats] => Array 
           (
            [count] => 8 
            [total] => 2186.4 
            [average] => 273.3 
           ) 

         ) 

        [5] => Array 
         (
          [date] => Array 
           (
            [year] => 2016 
            [month] => 3 
           ) 

          [currency] => USD 
          [stats] => Array 
           (
            [count] => 3 
            [total] => 865 
            [average] => 288.33333333333 
           ) 

         ) 

        [6] => Array 
         (
          [date] => Array 
           (
            [year] => 2016 
            [month] => 3 
           ) 

          [currency] => AUD 
          [stats] => Array 
           (
            [count] => 19 
            [total] => 127279 
            [average] => 6698.8947368421 
           ) 

         ) 

       ) 

     ) 

) 

Wie ich $ Wert von [Monat] erhalten kann in der Schleife ??

Hilf mir bitte!

+0

Beide Antworten hier unten sind gut, hängt davon ab, was Sie weiter mit dem ** 'Monat' machen wollen ** – izk

Antwort

1

Meinten Sie Sie versuchen, den "Monat" Index innerhalb Datum zugreifen?

Wenn ja, könnten Sie so etwas wie dies versuchen:

Sagen wir mal $ array Array ist.

foreach($array['resource']['data'] as $data) { 
    echo $data['date']['month']; // Prints every month. 
    echo "<br/>"; 
} 

Ich hoffe, dies hilft.

Verwandte Themen