$s =<<< JSON
[
{"title": "11111111","channel": {"country": "USA"}},
{"title": "222222222","channel": {"country": "UK"}},
{"title": "3333333","channel": {"country": "China"}}
]
JSON;
$json = json_decode($s);
$r = array_filter($json, function($json) { return $json->channel->country == "UK"; });
print_r($r);Array
(
[1] => stdClass Object
(
[title] => 222222222
[channel] => stdClass Object
(
[country] => UK
) ))
[
{"title": "11111111","channel": {"country": "USA"}},
{"title": "222222222","channel": {"country": "UK"}},
{"title": "3333333","channel": {"country": "China"}}
]
JSON;
$json = json_decode($s);
$r = array_filter($json, function($json) { return $json->channel->country == "UK"; });
print_r($r);Array
(
[1] => stdClass Object
(
[title] => 222222222
[channel] => stdClass Object
(
[country] => UK
) ))
解决方案 »
- 模式对话框返回给父窗口值的问题
- Notice: Undefined variable: submit in D:\phpnow\htdocs\web\title.php on line 5
- 求 短信网址 插件的例子写法,内附详细资料……
- 多维数组按照名称的字母排序
- MVC到底是指代码的那部分
- 下面一断代码,帮忙看看有什么问题,急,谢谢!!应该与Mysql有关
- 一个关于下载的小问题,在线等
- mail()的问题!急啊!
- PHP提问 1:大家现在用PHP的版本是多少,最新是多少,我学PHP应该用那个版本?是不是后缀由PHP3又改成PHP了?
- 请问 Imagick的$draw = new ImagickDraw();中的composite和compositeImage区别
- 当PHP页面没加载完成时,用户点击刷新了,怎么结束上次没加载完成的页面而重新加载?
- php中如何获取以下动态生成的text控件的个数,并且如何获取每个控件的值。
$s =<<< JSON
[
{"title": "11111111","channel": {"country": "USA"}},
{"title": "222222222","channel": {"country": "UK"}},
{"title": "3333333","channel": {"country": "China"}}
]
JSON;
$json = json_decode($s,true);
foreach($json as $v){
if ($v['channel']['country'] == 'UK'){$arr[] = $v;}
}
echo '<pre>';print_r($arr);
Array
(
[0] => Array
(
[title] => 222222222
[channel] => Array
(
[country] => UK
) ))