开发者

preg_replace problem

开发者 https://www.devze.com 2023-03-08 05:02 出处:网络
I have $_SERVER[\'DOCUMENT_ROOT\'] echoed, the problem is when it is echoed from xampp it shows, like this:

I have $_SERVER['DOCUMENT_ROOT'] echoed, the problem is when it is echoed from xampp it shows, like this:

C:/xampp/hdocs

and开发者_StackOverflow社区 when echoed from PHPed it shows

C:\\xampp\\htdocs.

I want to replace "C:\\xampp\\htdocs" with "C:/xampp/hdocs" but I'm not able to do so using preg_replace.

Kindly help me !


You don't need regex for that. Use the str_replace() fnction:

str_replace('\\', '/', $str);
0

精彩评论

暂无评论...
验证码 换一张
取 消