PHP preg_replace赢得';不起作用


PHP preg_replace won't work

据我所知,我完全按照规定做了这件事,但PCRE对我来说毫无意义,所以我要问你这个代码出了什么问题,为什么它说:

中偏移量为10的字符类缺少终止]

  $UrlTeams = preg_replace(
    array(
        "/['/'''40]['']?/",
        "/['.%]/",
        "/'&/"
    ),
    array(
        "/'-/",
        "",
        "'&amp';"
    ),
    $UrlTeams
  );

尝试:

$UrlTeams = preg_replace(
    array(
        "#[/'40'''']['''']?#",
        "#[.%]#",
        "#[&]#"
    ),
    array(
        "-",
        "",
        "&"
    ),
    $UrlTeams
  );