请教大牛们,如何将该字符串{sucess=[ttt,111],error=[rrr,ggg,vd]}处理成数组
如下
array(
'sucess' => array(
[0] => 'ttt',
[1] => '111'
),
'error'=> array(
[0] => 'rrr',
[1] => 'ggg',
[2] => 'vd'
)
)
------解决方案--------------------
php code$s={sucess=[ttt,111],error=[rrr,ggg,vd]};preg_replace('/(\w+)=\[(.*?)\]/e','$ar[$1]=explode(,,$2)',$s);print_r($ar);/*array( [sucess] => array ( [0] => ttt [1] => 111 ) [error] => array ( [0] => rrr [1] => ggg [2] => vd ))*/
