以下数组中包含JSON:
$row['modifiers']
如何访问此内的modifier_value
?
我试过了:
$row['modifiers']['modifier_value'];
这是阵列的外观:
[{"modifier_id":"","modifier_name":"Type","modifier_type":"custom","modifier_value":"Tour","option_id":"","price_mod":"","price_mod_inc_tax":""}]
答案 0 :(得分:3)
试试这个
<?php
$a = '[{"modifier_id":"","modifier_name":"Type","modifier_type":"custom","modifier_value":"Tour","option_id":"","price_mod":"","price_mod_inc_tax":""}]';
$decode = json_decode($a);
foreach ($decode as $arr){
echo $arr->modifier_name;
echo $arr->modifier_type;
// so on
}
?>