我有一个像
这样的字符串https:\/\/scontent.xx.fbcdn.net\/hphotos-xta1\/v\/t1.0-9\/p50x50\/11139440_1010664825611559_1305796970308877058_n.jpg?oh=6da07776dd8ba8270c2c32de2957b7d3&oe=560D0AF0
我想用preg_replace函数替换所有“\” 就像这样
https://scontent.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/p50x50/11139440_1010664825611559_1305796970308877058_n.jpg?oh=6da07776dd8ba8270c2c32de2957b7d3&oe=560D0AF0
示例:
我如何实现这一目标?
答案 0 :(得分:1)
为什么要使用,之后stripslashes()会为你做这件事:
<强>结果:强>
https://scontent.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/p50x50/11139440_1010664825611559_1305796970308877058_n.jpg?oh=6da07776dd8ba8270c2c32de2957b7d3&oe=560D0AF0
示例强>
<?php
$string = 'https:\/\/scontent.xx.fbcdn.net\/hphotos-xta1\/v\/t1.0-9\/p50x50\/11139440_1010664825611559_1305796970308877058_n.jpg?oh=6da07776dd8ba8270c2c32de2957b7d3&oe=560D0AF0';
echo stripslashes($string);