[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

str_replace "\" with "/"

Posted on 2005-04-18
3
Medium Priority
?
3,682 Views
Last Modified: 2012-06-27
What is the correct way to format and str_replace to change a backslash to a forward slash? I've tried:

str_replace( '\', '/', $string );

But that produces an error.
0
Comment
Question by:MaybeItsJeremy
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Diablo84 earned 2000 total points
ID: 13811090
Remember the backslash is the escape character so you have to escape the backslash with another backslash effectively, for example:

$string = "hello \ there";
$string = str_replace( '\\', '/', $string );
echo $string;

Diablo84
0
 

Author Comment

by:MaybeItsJeremy
ID: 13811134
Hahahahaha. I knew that, but for some reason I kept trying to edit different things on the second parimeter instead of the first. Thank you. :)
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 13811163
no problem :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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
Course of the Month18 days, 12 hours left to enroll

834 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