Reputation: 4755
I'm trying to strip some slashes with the traditional stripslashes
function and am getting odd results:
echo stripslashes('\\\\');
This gives me: \
echo stripslashes('\\\\\\\\\\\\');
// there should be 12 slashes above
This gives me: \\\
(there should be three slashes here. Even SO is being weird with it)
It's eating double the slashes >.<
However when I plug the same input to http://www.tools4noobs.com/online_php_functions/stripslashes/ the result comes out fine?
Anyone know what's going on? How can I control stripslashes' appetite and make it stop double gobbling these sloshes?
Upvotes: 0
Views: 1232
Reputation: 15106
A backslash \
escapes one character following it. In order to print a backslash, you need two:
\\
\\\\
gives you two backslashes since each backslash escapes the one following it.
stripslashes('\\\\');
strips one backslash from the remaining two.
Upvotes: 1