My开发者_Python百科 original string look like this .
25\\\" height x 12\\\" width x 9\\\
but i want to remove these slashes from the sting like the below text.
I used stripslashes function , but gives only 25 .
25" height x 12" width x 9
You make it sound like you have double slashes added. Here is a quick block of code that tests a few different cases. And in 3/4 of the var_dumps it prints the data correctly. The extra slashes are to escape string encoding. Hopefully if you play around with the code below, it will help figure out the problem in your string.
<?php
$s = "25\\\\\" height x 12\\\\\" width x 9\\\\";
var_dump(stripslashes($s));
var_dump(stripslashes(stripslashes($s)));
$s = "25\\\" height x 12\\\" width x 9\\";
var_dump(stripslashes($s));
var_dump(stripslashes(stripslashes($s)));
?>
StripSlashes
Good for this or str_replace
You can also use str_replace like this
$str='25\\\" height x 12\\\" width x 9\\\""'; echo(str_replace("\\", ' ',$str));
Please used stripslashes function. I used and i got the following result:
echo stripslashes ('25\\" height x 12\\" width x 9\\');
output: 25" height x 12" width x 9
精彩评论