我尝试输出一个数组,如下所示:
durations":[{"months":"36"},{"months":"48"}],"duration_default":"60","insurance_factor":"0","lease_factor":"0.4637","create_fee":"2500
数组是多维的,如下所示:
Array ( [durations] => Array ( [0] => Array ( [months] => 36 ) [1] => Array ( [months] => 48 ) ) [duration_default] => 60 [insurance_factor] => 0 [lease_factor] => 44 [create_fee] => 2500 ) )
我试过这个:
foreach ($post_fields as $key=>$item){
echo ""$key" : "$item", ";
}
但最后还是这样:
data-calc="{"durations" : "Array", "duration_default" : "60", "insurance_factor" : "0.9909", "lease_factor" : "44", "create_fee" : "2500", "frequency" : "month", "min_price" : "2222", "margins" : "Array",
如何提取嵌套数组?
1条答案
按热度按时间5ktev3wc1#
它是JSON,所以尝试以下代码:
$post_fields = json_decode($post_fields , true);