这是JSON数组吗? [英] Is this a JSON array?
问题描述
这是JSON数组吗: http://flamencopeko.net/icons_ajax.php ?>
来源: http://flamencopeko.net/icons_ajax.txt
$urls = array(); foreach (glob(dirname(__FILE__) . '/ico/*.gif') as $file) { $urls[] = 'http://flamencopeko.net/ico/' . basename($file); };
$index = 0;
if (isset($_GET['index'])) {
$index = (int) $_GET['index'];
if ($index > (count($urls) - 1)) {
// Out of bounds, reset
$index = 0;
}
}
$previous = $index - 1;
$next = $index + 1;
if ($previous < 0) {
$previous = count($urls) - 1;
}
if ($next == count($urls)) {
$next = 0;
}
echo json_encode(array(
'total' => count($urls),
'url' => $urls[$index],
'next' => $next,
'prev' => $previous,
'alls' => $urls
));
我正在尝试将其与php一起使用.与JavaScript一起使用.我已经尝试过json_decode()等等,但是还没有输出.
我喜欢在 http上使用在线json查看器://jsonviewer.stack.hu/-显示您有一个有效的json对象;您可以使用它来查看它包含一些标头信息和"alls"数组中的406个图像数组.
Is this a JSON array: http://flamencopeko.net/icons_ajax.php?
Source: http://flamencopeko.net/icons_ajax.txt
$urls = array(); foreach (glob(dirname(__FILE__) . '/ico/*.gif') as $file) { $urls[] = 'http://flamencopeko.net/ico/' . basename($file); };
$index = 0;
if (isset($_GET['index'])) {
$index = (int) $_GET['index'];
if ($index > (count($urls) - 1)) {
// Out of bounds, reset
$index = 0;
}
}
$previous = $index - 1;
$next = $index + 1;
if ($previous < 0) {
$previous = count($urls) - 1;
}
if ($next == count($urls)) {
$next = 0;
}
echo json_encode(array(
'total' => count($urls),
'url' => $urls[$index],
'next' => $next,
'prev' => $previous,
'alls' => $urls
));
I'm trying to use it with php. Works with JavaScript. I've tried json_decode() and more, but no output yet.
I like to use the online json viewer at http://jsonviewer.stack.hu/ - which shows you have a valid json object; which you could use to see that it consists of some header info and an array of 406 images in the 'alls' array.
这篇关于这是JSON数组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!