0^50411^1^10^5.0000^1900-01-01^0^ 10 ^58^元/人^^^^友邦保险$1^50411^1^20^5.0000^1900-01-01^0^ 20 ^59^元/人^^^^平安保险$2^57777^1^60^50.0000^2012-12-19^633183^ 60 ^13^元/人^^^^AAAAAA$3^57777^1^60^50.0000^2012-12-20^633183^ 60 ^13^元/人^^^^BBBBBB
这一串字符,我想用  /\$\d/ 来作为正则分割  由 $1,$2,$3 分割开的,但是这么写并不行!然后再用 ^^^^ 分割每一个数组子元素,获得 友邦保险 ,平安保险 等这些名字/\^\^\^\^/ 这么写也不行,好奇怪!

解决方案 »

  1.   

    $s = <<< TXT
    0^50411^1^10^5.0000^1900-01-01^0^ 10 ^58^元/人^^^^友邦保险$1^50411^1^20^5.0000^1900-01-01^0^ 20 ^59^元/人^^^^平安保险$2^57777^1^60^50.0000^2012-12-19^633183^ 60 ^13^元/人^^^^AAAAAA$3^57777^1^60^50.0000^2012-12-20^633183^ 60 ^13^元/人^^^^BBBBBB
    TXT;
    preg_match_all('/[^^]+$/m', $s, $r);
    print_r($r);Array
    (
        [0] => Array
            (
                [0] => 友邦保险            [1] => 平安保险            [2] => AAAAAA            [3] => BBBBBB
            ))
      

  2.   

    Warning: preg_match_all() expects parameter 2 to be string, array given in F:\APMServ5.2.6\www\htdocs\order\bakup\1218\test.php on line 24