将JSON字符串转换为数组

时间:2015-11-19 10:00:13

标签: php arrays

有没有人知道将这个字符串转换为数组的优雅方式

{"Order_status":{"order_country":"IN","order_flat":0,"order_currncy":"INR"}}

需要将上述字符串转换为数组

array('Order_staus'=>array('order_country'=>'IN','order_flat'=>0,'order_currency'=>'INR'))

2 个答案:

答案 0 :(得分:0)

使用json_decode

<?php
$s = '{"Order_status":{"order_country":"IN","order_flat":0,"order_currncy":"INR"}}';
var_dump(json_decode($s, true));

答案 1 :(得分:0)

使用json_decode($JSONstr)将json字符串转换为php数组

和明智的诗句json_encode($phparray)转换为jsonstr

相关问题