How can I handle an array in an array?
Like this:
Array
(
[page] => 1
[pages] => 391
[perpage] => 3
[total] => 1171
[photo] => Array
(
[0] => Array
(
[id] => 4539740346
开发者_StackOverflow中文版 [owner] => 21229296@N03
[secret] => 3b10921450
[server] => 4040
[farm] => 5
[title] => ~ Berry One ~
[ispublic] => 1
[isfriend] => 0
[isfamily] => 0
)
edit: how to echo all of it? here is the array looks like: http://www.qeeker.com/flickr
You can get values from the array like this:
echo $a['photo'][0]['ispublic']; //1
UPDATE:
In the comments you stated you want to display the photo stuff. In PHP, foreach
can be used to iterate through an array:
foreach ($a['photo'] as $photo) {
//$photo refers to the current photo on every iteration
echo $photo['ispublic'];
}
This snippet will echo the ispublic
property of EVERY photo in the array. If you want to echo all the properties of all photos, you can use a nested foreach
(one inside another).
$var = array('page' => 1,
'pages' => 391,
'perpage' => 3,
'total' => 1171,
'photo' => array(array('id' => 4539740346,
'owner' => '21229296@N03'
'secret' => '3b10921450'
'server' => 4040
'farm' => 5
'title' => '~ Berry One ~'
'ispublic' => 1
'isfriend' => 0
'isfamily' => 0
)
)
);
var_dump($var);
精彩评论