从字符串叶子中删除撇号39

Sty*_*hon 0 php replace special-characters

我正在尝试从字符串中删除特殊字符,准备在URL中使用它.这是我现在的代码:

public function __construct($string) {

    $remove = array("!", "'", '"', "(", ")", ";", "@", "&", "=", "$", ",", "/", "?", "%", "#", "[", "]");

    var_dump($string);
    $this->string = $string;
    $this->string = str_replace($remove, "", $this->string);
    //$this->string = preg_replace("/[\s_\-:+]+/", "-", strtolower($this->string));
    var_dump($this->string);

}
Run Code Online (Sandbox Code Playgroud)

这就是它的输出:

string(16) "Today's Quiz" string(13) "Today39s Quiz"

这没有任何意义......我决不会转换特殊字符或任何东西,那么39来自哪里?我无法追踪它.

Nie*_*sol 5

如字符串的长度所示,您的输入实际上是:

Today's Quiz
1234567890123456 -> 16 characters
Run Code Online (Sandbox Code Playgroud)

由于你正在修剪& #;角色,结果是剩下的39.