0

我想要做的是在网页上以 ul li 格式显示朋友列表和他们的图像,
我有 json 解码的字符串数组,其中包含用户信息。我用 PHP 怎么做?

object(stdClass)#4 (4){["entries"]=>array(3){[0]=>object(stdClass)#5 (10){["uid"]=>float(1.5555133825854E+14)["photo"]=>string(90) "https://m.ak.fbcdn.net/profile.ak/hprofile-ak-prn1/323887_155551338258538_1152153357_q.jpg"["type"]=>string(4) "user"["text"]=>string(13) "shikhadamodar"["path"]=>string(17) "/shikha.damodar.1"["category"]=>string(6) "Madiun"["names"]=>array(1){[0]=>string(13) "shikhadamodar"}["index_rank"]=>int(-1)["needs_update"]=>bool(true)["non_title_tokens"]=>string(6) "madiun"}[1]=>object(stdClass)#6 (10){["uid"]=>float(1.5555133217343E+14)["photo"]=>string(90) "https://m.ak.fbcdn.net/profile.ak/hprofile-ak-snc3/273318_155551332173428_2131571532_q.jpg"["type"]=>string(4) "user"["text"]=>string(14) "shreya damodar"["path"]=>string(14) "/my.devprofile"["category"]=>string(5) "Nilai"["names"]=>array(1){[0]=>string(13) "shreyadamodar"}["index_rank"]=>int(-1)["needs_update"]=>bool(true)["non_title_tokens"]=>string(5) "nilai"}[2]=>object(stdClass)#7 (10){["uid"]=>float(1.5555558723211E+14)["photo"]=>string(83) "https://m.ak.fbcdn.net/profile.ak/hprofile-ak-prn1/41332_155555587232111_3158_q.jpg"["type"]=>string(4) "user"["text"]=>string(9) "neha neha"["path"]=>string(12) "/neha.neha34"["category"]=>string(18) "New York,New York"["names"]=>array(1){[0]=>string(9) "Neha neha"}["index_rank"]=>int(-1)["needs_update"]=>bool(true)["non_title_tokens"]=>string(18) "new york,new york"}}["token"]=>string(12) "1333551453-7"["display_token"]=>int(5)["display_ttl"]=>int(1333541132)}

这样做的有效方法是什么?

4

2 回答 2

0

做这个

让我们考虑您的 json_decoded 代码在 $arr 变量数组中

foreach ($arr->entries as $val) {
    echo "<ul><li>".$val['uid']."</li></ul>";
    //put your li code here
}

像这样的东西

于 2013-04-22T13:07:01.920 回答
0
foreach ($jarr->entries as $val) {
    echo "<ul><li>".$val->uid."</li></ul>";
}
于 2013-04-22T13:32:04.483 回答