开发者

How can I remove escape characters using PHP?

开发者 https://www.devze.com 2023-04-12 12:20 出处:网络
I have the following text $text = \"\\\\vct=140\\\\Araignée du soir espoir,araignée du matin,espoir du matin.\"

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 s开发者_开发知识库tring?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消