我正在尝试查找一个巨大数组(7000 多个项目)的结果,出于某种原因,我之前用于另一个项目的脚本一直返回错误,或者我可能忘记了一些东西。
我正在尝试对数组进行排序并找到变量中列出的两个项目。这是代码:
$.getJSON('proxy.php?url=http://api.bukget.org/api/plugins', function(data){
var list = ['essentials', 'worldguard'];
//console.log(data);
$.each(data, function(i, plugin){
if (plugin === list) {
console.log('found!');
} else {
return false;
}
});
});
我的代码中缺少什么?
使用代理:
<?php
if (!isset($_GET['url'])) die();
$url = urldecode($_GET['url']);
$url = 'http://' . str_replace('http://', '', $url); // Avoid accessing the file system
echo file_get_contents($url);
?>
这使得数据(片段):
["a5h73y", "ab-marriage", "abacus", "abag", "abandonedcarts", "abilitytrader", "abitofrealism", "aboot", "absorbchests", "acc", "acceptdarules", "acceptrules", "accesscontrol", "accessories", "accident-tnt", "accountlock", "achat", "achievement", "achievements", "acientcave", "acommands", "actionzones", "activator", "activityhistory", "activitypromotion", "activitytracker"]