-1

我有一个字符串,看起来像:

["DZ_Backpack_EP1",[["M4A1"],["M16A2]],[["ItemWaterbottle","FoodSteakCooked","ItemPainkiller","ItemSodaPepsi","ItemBloodbag","ItemMorphine","ItemEpinephrine","ItemBandage"],[1,2,1,1,1,1,1,1]]]

Ant 我需要得到这个数组:

DZ_Backpack_EP1 = array(
                 ['weapons'] => array (
                             [0] => 'M4A1',
                             [1] => 'M16A2' 
                             ),
                 ['items'] => array (
                             ['ItemsList'] => array ( 
                                 [0] = > 'ItemWaterbottle',
                                 [1] = > 'FoodSteakCooked',
                                 [2] = > 'ItemPainkiller',
                                 [3] = > 'ItemSodaPepsi',
                                 [4] = > 'ItemBloodbag',
                                 [5] = > 'ItemMorphine',
                                 [6] = > 'ItemEpinephrine',
                                 [7] = > 'ItemBandage'),
                             ['ItemsCount'] => array ( 
                                 [0] = > 'ItemWaterbottle',
                                 [1] = > 'FoodSteakCooked',
                                 [2] = > 'ItemPainkiller',
                                 [3] = > 'ItemSodaPepsi',
                                 [4] = > 'ItemBloodbag',
                                 [5] = > 'ItemMorphine',
                                 [6] = > 'ItemEpinephrine',
                                 [7] = > 'ItemBandage'
                                 )
                             )
                 )

我尝试将这个示例PHP - 字符串编辑为多维数组,但没有运气。有任何想法吗?

4

1 回答 1

6

看起来你只需要json_decode.

于 2012-07-06T13:44:49.140 回答