How can I remove escape characters using PHP?

…衆ロ難τιáo~ 提交于 2019-12-04 03:26:55

问题


I have the following text

$text = "\\vct=140\\Araignée du soir espoir,araignée du matin,espoir du matin."

I want to remove the escape characters using php..I do not want to use stripslashes since it is server dependent..

I want to remove the '\' before the '\vct=140' and the '\' before '\Arai....' How can I remove them from the string?


回答1:


As far as I can tell stripslashes works as per the manual:

<?php
$string = '\\\\vct=140\\\\Araignée du soir espoir.';
echo $string, "\n";
echo stripslashes($string), "\n";

Which outputs:

\\vct=140\\Araignée du soir espoir.
\vct=140\Araignée du soir espoir.

Sequence \\ is in list of escape sequences for special characters so you got to escape slashes twice.



来源:https://stackoverflow.com/questions/7749690/how-can-i-remove-escape-characters-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!