如何使用Javascript或jQuery过滤JSON数据?
这是我的JSON数据:
[{"name":"Lenovo Thinkpad 41A4298","website":"google"},
{"name":"Lenovo Thinkpad 41A2222","website":"google"},
{"name":"Lenovo Thinkpad 41Awww33","website":"yahoo"},
{"name":"Lenovo Thinkpad 41A424448","website":"google"},
{"name":"Lenovo Thinkpad 41A429rr8","website":"ebay"},
{"name":"Lenovo Thinkpad 41A429ff8","website":"ebay"},
{"name":"Lenovo Thinkpad 41A429ss8","website":"rediff"},
{"name":"Lenovo Thinkpad 41A429sg8","website":"yahoo"}]
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
obj1 = JSON.parse(jsondata);
Run Code Online (Sandbox Code Playgroud)
现在我只想要包含网站的名称和网站数据等于"雅虎"
我使用远程 url 和 json 响应(新 typeahead.js)
我的 JavaScript :
$(document).ready(function() {
$('input.country').typeahead({
valueKey: 'name',
remote : {
url : 'example.in/d.php?query=%QUERY',
filter: function (parsedResponse) {
var dataset = [];
for (i = 0; i < parsedResponse.length; i++) {
dataset.push({
name: parsedResponse[i].name
});
}
if (parsedResponse.length == 0) {
dataset.push({
name: "No results"
}); }
return dataset;
},
},
});;
})
Run Code Online (Sandbox Code Playgroud)
我的 json 响应:
[{"name":"诺基亚 110",url:"example.com/nokia-110"},{"name":"诺基亚 210",url:"example.com/nokia-210"}]
那么如何在所选名称上提供 URL 链接?
如果文件早于当前日期(今天),我该如何删除文件
step 1 : Check file last modification date
step 2 : If file date older than Today Date than Delete file
step 3 : Else do nothing
Run Code Online (Sandbox Code Playgroud)
注意:我不想删除超过24小时的文件(我只想删除早于当前日期)
如何将代码从核心PHP转换为Pthread代码
我的核心PHP代码:
require_once 'xyz.php';
$count="0";
foreach($sites as $site)
{
require_once 'allsite/'.$site.'.php';
$siteObj = new $site;
$data[$count] = $siteObj->getsiteData($query,$cat);
$count++;
}
Run Code Online (Sandbox Code Playgroud)
如何以Pthread方式执行foreach循环代码(多线程)
在foreach循环执行完成正常PHP的东西完成后(在foreach循环后意味着没有多线程)
注意:我已经在PHP中安装并配置了pthread
这是静态条件
var as = $(json).filter(function (i, n) {
return n.website === 'yahoo' || n.website === 'ebay'
});
Run Code Online (Sandbox Code Playgroud)
但想动态检查我的数组值是什么
weblist[0] = "yahoo";
weblist[1] = "google";
weblist[2] = "ebay";
weblist[3] = "rediff";
weblist[4] = "amazon";
Run Code Online (Sandbox Code Playgroud)
我想使用上面的数组值来检查条件
var as = $(json).filter(function (i, n) {
return n.website === 'yahoo' || n.website === 'google' || n.website === 'ebay' || n.website === 'rediff' || n.website === 'amazon'
});
Run Code Online (Sandbox Code Playgroud)
怎么可能?
如何使用htaccess规则为mod_pagespeed排除一些目录....
注意:我只需要禁用某些目录而不是所有文件和文件夹
我想在两个文本之间找到相似的单词数量
例
$str1=the cat is on the roof
$str2=the mouse is on the roof
Run Code Online (Sandbox Code Playgroud)
在$ str1和$ str2中,the,on,on, words字是相似的
因此输出数量为5或者百分比为86%
我尝试使用similar_text()函数,但这个函数不能正常工作.
我想过滤 JSON 数据中 250 到 800 之间的价格范围
我的 JSON 数据:
var data = [{
"name": "Lenovo Thinkpad 41A4298",
"Price": 200
}, {
"name": "Lenovo Thinkpad 41A2222",
"Price": 200
}, {
"name": "Lenovo Thinkpad 41Awww33",
"Price": 6700
}, {
"name": "Lenovo Thinkpad 41A424448",
"Price": 600
}, {
"name": "Lenovo Thinkpad 41A429rr8",
"Price": 4200
}, {
"name": "Lenovo Thinkpad 41A429ff8",
"Price": 2200
}, {
"name": "Lenovo Thinkpad 41A429ss8",
"Price": 200
}, {
"name": "Lenovo Thinkpad 41A429sg8",
"Price": 500
}];
Run Code Online (Sandbox Code Playgroud)
如何在 Javascript 或 …
jquery ×4
javascript ×3
php ×3
json ×2
.htaccess ×1
arrays ×1
filter ×1
foreach ×1
fuzzy-logic ×1
match ×1
pagespeed ×1
pthreads ×1
typeahead ×1
typeahead.js ×1