您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

字符串处置成数组

2025/10/1 13:20:33发布22次查看
字符串处理成数组
请教大牛们,如何将该字符串{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 ))*/

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product