请教大牛们,如何将该字符串"{SUCESS=[ttt,111],ERROR=[rrr,ggg,vd]}"处理成数组
如下
array(
   'SUCESS' => array(
           [0] => 'ttt',
           [1] => '111'
    ),
   'ERROR'=> array(
           [0] => 'rrr',
           [1] => 'ggg',
           [2] => 'vd'
    )

解决方案 »

  1.   

    $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
            ))
    */
      

  2.   

    Notice: Use of undefined constant sucess - assumed 'sucess' in 
    Notice: Use of undefined constant error - assumed 'error' in
    会报未定义错误,这个怎么避免?
      

  3.   

    脚本中加上: error_reporting(E_ALL & ~NOTICE);