截取多个JSON的参数值遇到有关问题
程序员文章站
2024-02-13 22:35:04
...
截取多个JSON的参数值遇到问题。
POST获取的JSON数据 [{"Name":"PM","Value":"224"},{"Name":"WD","Value":"25"},{"Name":"SD","Value":"34"},]
如何截取 Name=WD 的Value?
求代码。
------解决方案--------------------
POST获取的JSON数据 [{"Name":"PM","Value":"224"},{"Name":"WD","Value":"25"},{"Name":"SD","Value":"34"},]
如何截取 Name=WD 的Value?
求代码。
------解决方案--------------------
$json = '[{"Name":"PM","Value":"224"},{"Name":"WD","Value":"25"},{"Name":"SD","Value":"34"}]';
$jsonArr = json_decode($json) ;
foreach ($jsonArr as $value) {
if($value->Name == 'WD'){
echo $value->Value."
";
}
}
相关文章
相关视频