I’m trying to replace / and \ with //:
$path = 'C:\wamp\www\mysite/bla/bla';
str_replace(array("\/", "\\"), array("\/\/", "\/\/"), $path);
but it doesn’t work:(
I get C:\\/wamp\\/www\mysite/bla/bla …
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is not necessary to escape the forward slash, so it is interfering with the pattern match.
Also,
str_replacereturns the replacement, it is not a byRef function so you’ll need to store the return in a variable (docs).See it happen: http://codepad.org/CNr8P79m