Replace all forward slashes with backward slashes



        $txtName = ereg_replace ('\\', '/', $txtName);

is giving me the following warning:
     Warning: ereg_replace(): REG_EESCAPE in /home/scipts/test.php

How can I replace all forward slashes ( \ ) with backward slashes ( / )  ????

LVL 16
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

why don't you use
$txtName = str_replace('\\', '/', $txtName)
for that purpose?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If you want to do it with ereg_replace use
$txtName = ereg_replace ('\\\\', '/', $txtName);

It's because the \\ will be turned to \ for the argument of the ereg_replace and as the \ is a special charachter it needs to be escaped also. So you need that 4 backslahes to simulate one real backslash in your string.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.