【发布时间】:2014-01-26 20:25:03
【问题描述】:
这是一个 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() 等等,但还没有输出。
【问题讨论】:
-
json_decode() 是否输出任何错误?是的,这在我看来就像 JSON。
-
我不太确定你的意思,但该链接似乎非常有效的 JSON
-
不,它不是 JSON 数组,您要查找的数组可能是
alls属性。 -
它不是一个数组。一个属性是一个数组。
-
您可以使用jsonlint.com 进行 JSON 验证
标签: javascript php arrays json