$string = "my text has \"double quotes\" and 'single quotes'";
How to remove all types of quotes (different languages) from $string
?
如何从$ string中删除所有类型的引号(不同的语言)?
1 个解决方案
#1
92
str_replace('"', "", $string);
str_replace("'", "", $string);
I assume you mean quotation marks?
我假设你的意思是引号?
Otherwise, go for some regex, this will work for html quotes for example:
否则,去一些正则表达式,这将适用于HTML引号,例如:
preg_replace("/<!--.*?-->/", "", $string);
C-style quotes:
C风格的报价:
preg_replace("/\/\/.*?\n/", "\n", $string);
CSS-style quotes:
CSS风格的报价:
preg_replace("/\/*.*?\*\//", "", $string);
bash-style quotes:
bash风格的报价:
preg-replace("/#.*?\n/", "\n", $string);
Etc etc...
等等...
#1
92
str_replace('"', "", $string);
str_replace("'", "", $string);
I assume you mean quotation marks?
我假设你的意思是引号?
Otherwise, go for some regex, this will work for html quotes for example:
否则,去一些正则表达式,这将适用于HTML引号,例如:
preg_replace("/<!--.*?-->/", "", $string);
C-style quotes:
C风格的报价:
preg_replace("/\/\/.*?\n/", "\n", $string);
CSS-style quotes:
CSS风格的报价:
preg_replace("/\/*.*?\*\//", "", $string);
bash-style quotes:
bash风格的报价:
preg-replace("/#.*?\n/", "\n", $string);
Etc etc...
等等...