Forum Moderators: coopster
Can someone please give me the syntax to deal with reserved characters in php? I'm having the following problem.
$string = "./blah/bloo/bling";
//I'd like to remove the starting "." to produce
// "/blah/bloo/bling"
// Does not work
ereg_replace(".", $string);
Can someone please tell me how this is done?
Thanks,
Chris
<?php
$stuff="blah blah-- blah";
$patterns[0] = "--";
$replacements[0] = "—";
$newstuff= str_replace($patterns, $replacements, $stuff);
echo $newstuff;?>
$patterns[0] = "--";
I just tried that snippet of yours and it worked great.
sooo.... what version of php are you running? This is from the manual
In PHP 4.0.5 and later, every parameter to str_replace() can be an array.
If this is the case then make sure your $patterns and $replacements are not arrays or else upgrade your php.
$newstuff = str_replace("--","&8212;",$stuff);
I saw some examples of ereg_replace whose search patterns looked like "/blah/" instead of "blah"-- I think my search syntax is what's wrong but I don't know how to fix it.