facebook fql 结果到 json_encode 数组
新手,我下面的代码输出如下 [{"src":"http","src":"http"},{"src":"http","src":"http"}]< /code> 使用 json_encode。但是我的要求是这样的
[["http","http"],["http","http"]]
//to get album cover
$fql2 = "select src from photo where pid = '" . $values['cover_pid'] . "'";
$param2 = array(
'method' => 'fql.query',
'query' => $fql2,
'callback' => ''
);
$fqlResult2 = $facebook->api($param2);
$jsarr = array();
foreach( $fqlResult2 as $keys2 => $values2){
}
if ($values['name'] != 'Profile Pictures'){
$jsarr['src'] = $album['src'];
$count += 1;
if ($count == 1){
echo "[";}
else {
echo ",";}
echo json_encode($values2);
}
}
echo "]";
}
?>
我的 json_encode 输出是这样的
[{"src":"http:\/\/photos-c.ak.fbcdn.net\/hphotos-ak-snc6\/251383_221168744573533_221167777906963_849177_3220954_s.jpg"},{"src":"http:\/\/photos-d.ak.fbcdn.net\/hphotos-ak-ash4\/248958_221168431240231_221167777906963_849167_3802855_s.jpg"}]
我如何以这种方式输出它
[["http:\/\/photos-c.ak.fbcdn.net\/hphotos-ak-snc6\/251383_221168744573533_221167777906963_849177_3220954_s.jpg"],["http:\/\/photos-d.ak.fbcdn.net\/hphotos-ak-ash4\/248958_221168431240231_221167777906963_849167_3802855_s.jpg"]]
newbie here, my code below outputs like this [{"src":"http","src":"http"},{"src":"http","src":"http"}]
using json_encode. however my requirement would be like this [["http","http"],["http","http"]]
//to get album cover
$fql2 = "select src from photo where pid = '" . $values['cover_pid'] . "'";
$param2 = array(
'method' => 'fql.query',
'query' => $fql2,
'callback' => ''
);
$fqlResult2 = $facebook->api($param2);
$jsarr = array();
foreach( $fqlResult2 as $keys2 => $values2){
}
if ($values['name'] != 'Profile Pictures'){
$jsarr['src'] = $album['src'];
$count += 1;
if ($count == 1){
echo "[";}
else {
echo ",";}
echo json_encode($values2);
}
}
echo "]";
}
?>
my json_encode output is like this
[{"src":"http:\/\/photos-c.ak.fbcdn.net\/hphotos-ak-snc6\/251383_221168744573533_221167777906963_849177_3220954_s.jpg"},{"src":"http:\/\/photos-d.ak.fbcdn.net\/hphotos-ak-ash4\/248958_221168431240231_221167777906963_849167_3802855_s.jpg"}]
how do i output it this way
[["http:\/\/photos-c.ak.fbcdn.net\/hphotos-ak-snc6\/251383_221168744573533_221167777906963_849177_3220954_s.jpg"],["http:\/\/photos-d.ak.fbcdn.net\/hphotos-ak-ash4\/248958_221168431240231_221167777906963_849167_3802855_s.jpg"]]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种简单的方法是将
json_encode
结果保存到变量中,然后 str_replace{
和}
字符。所以你的代码将变成:
One simple way would be to save the
json_encode
result to a variable, and then str_replace the{
and}
characters.So your code would become: