string replace - str_replace

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
baddis
Forum Newbie
Posts: 1
Joined: Thu Oct 02, 2008 4:25 pm

string replace - str_replace

Post by baddis »

How can I do a str_replace for "\" when I try "\" I get syntax error

$output = str_replace("\", "\", $stringData);
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: string replace - str_replace

Post by VladSun »

\ is used for escaping so you should escape the "escape char" :) like this:

$s= "\\"; // $s now is exactly \
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply