Accessing an array that is inside another

Asked

Viewed 22 times

2

I have the following array

array(2) {
  [0]=>
  array(1) {
    ["data"]=>
    string(19) "2015-11-20 00:33:53"
  }
  [1]=>
  array(1) {
    ["data"]=>
    string(19) "2015-11-20 08:24:50"
  }
}

How do I access both ['data']'s ?

1 answer

3


As follows:

echo $seuArray[0]['data'];
echo $seuArray[1]['data'];

Or for a tie for:

for ($i = 0; $i < count($seuArray); $i++) {
    echo $seuArray[$i]['data'];
}

Or with foreach loop:

foreach($seuArray as $item) {
    echo $item['data'];
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.