如何在php中去掉这里引号前的\
8 个解决方案
#1
$str = <<<TEXT
<p style=\"text-align:center;\"> < img src=\"http://127.0.0.1/data/images/2017/09/26/20170926141255_51116.png\" alt=\"\" border=\"0\" /></p ><br/><p>
TEXT;
$str = preg_replace("#\\\\\"#",'"',$str);
echo '<pre>';
var_dump($str);
echo '</pre>';
#2
stripslashes()
#3
没办法,这个方法试过了,死活去不掉
#4
用这个方法无效,还是去不掉
#5
$s = '<p style=\"text-align:center;\"> <img src=\"http://127.0.0.1/data/images/2017/09/26/20170926141255_51116.png\" alt=\"\" border=\"0\" /></p><br/><p>
';
echo stripslashes($s);
<p style="text-align:center;"> <img src="http://127.0.0.1/data/images/2017/09/26/20170926141255_51116.png" alt="" border="0" /></p><br/><p>
#6
你在哪里看到 \ 的?
#7
$str = '<p style=\"text-align:center;\"> <img src=\"http://127.0.0.1/data/images/2017/09/26/20170926141255_51116.png\" alt=\"\" border=\"0\" /></p><br/><p>';
$rst = preg_replace('/\\\\(?=")/', '', $str);
var_dump($rst);
#8
#1
$str = <<<TEXT
<p style=\"text-align:center;\"> < img src=\"http://127.0.0.1/data/images/2017/09/26/20170926141255_51116.png\" alt=\"\" border=\"0\" /></p ><br/><p>
TEXT;
$str = preg_replace("#\\\\\"#",'"',$str);
echo '<pre>';
var_dump($str);
echo '</pre>';
#2
stripslashes()
#3
没办法,这个方法试过了,死活去不掉
#4
用这个方法无效,还是去不掉
#5
$s = '<p style=\"text-align:center;\"> <img src=\"http://127.0.0.1/data/images/2017/09/26/20170926141255_51116.png\" alt=\"\" border=\"0\" /></p><br/><p>
';
echo stripslashes($s);
<p style="text-align:center;"> <img src="http://127.0.0.1/data/images/2017/09/26/20170926141255_51116.png" alt="" border="0" /></p><br/><p>
#6
你在哪里看到 \ 的?
#7
$str = '<p style=\"text-align:center;\"> <img src=\"http://127.0.0.1/data/images/2017/09/26/20170926141255_51116.png\" alt=\"\" border=\"0\" /></p><br/><p>';
$rst = preg_replace('/\\\\(?=")/', '', $str);
var_dump($rst);