我生成了这样的数组。我如何访问返回的正文?我得到一个循环来获取数据值以接收此列表构建。我知道如何获得totalResults,但我无法深入了解数组。感谢。
foreach ($searchres as $videout){
echo '<li id="cNa9dzezrd8"><img src="http://i.ytimg.com/vi/cNa9dzezrd8/0.jpg"><br>';
echo '<div class="description">';
echo '<h3>Danny McCarthy - Silver Scrape...</h3>';
echo '<span>Author : </span> Kavvson<br>';
echo '<span>Views : </span> 161654<br>';
echo '</div></li>';
}
数组
array(4) {
["totalResults"]=>
string(3) "588"
["startIndex"]=>
string(1) "1"
["itemsPerPage"]=>
string(1) "2"
["results"]=>
array(2) {
[0]=>
array(12) {
["id"]=>
string(11) "cNa9dzezrd8"
["title"]=>
string(67) "Danny McCarthy - Silver Scrapes ( Extended culineR & Kavvson Edit )"
["description"]=>
string(160) "SoundCloud : Original version : Danny McCarthy - Silver Scrapes Edited by culineR and Me {} culineR www.Facebook.com/devonculineR www.Sou..."
["uploaded"]=>
string(19) "04/05/2013 00:20:51"
["duration"]=>
string(3) "274"
["author"]=>
string(8) "kavvsona"
["category"]=>
string(5) "Music"
["url"]=>
string(71) "http://www.youtube.com/watch?v=cNa9dzezrd8&feature=youtube_gdata_player"
["rating"]=>
string(8) "4.973549"
["views"]=>
string(6) "161654"
["comments"]=>
string(3) "147"
["thumbnails"]=>
array(4) {
[0]=>
string(39) "http://i.ytimg.com/vi/cNa9dzezrd8/0.jpg"
[1]=>
string(39) "http://i.ytimg.com/vi/cNa9dzezrd8/1.jpg"
[2]=>
string(39) "http://i.ytimg.com/vi/cNa9dzezrd8/2.jpg"
[3]=>
string(39) "http://i.ytimg.com/vi/cNa9dzezrd8/3.jpg"
}
}
答案 0 :(得分:1)
假设$arr
拥有您的数组,然后尝试
foreach($arr['results'] as $ar){
echo $ar['id']; // and so on
}