Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Replace all forward slashes with backward slashes

Posted on 2004-10-21
2
Medium Priority
?
2,603 Views
Last Modified: 2012-08-14
Hello.

This:

        $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 ( / )  ????

Thanks!
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 1776 total points
ID: 12373625
why don't you use
$txtName = str_replace('\\', '/', $txtName)
for that purpose?
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12373664
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.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question