Page 2 of 2
Posted: Thu Nov 09, 2006 4:29 pm
by $var
wow, so over a year later... and i'm back checking out how to do a string replace to eliminate apostrophes in database entries.
this is what i've got: str_replace("'","'",'<br />',$_POST["solution"])
i need it to allow "'" and replace line breaks with "<br />"
thank you!
Posted: Thu Nov 09, 2006 4:43 pm
by feyd
str_replace() takes three arguments. You're giving it four.
Posted: Fri Nov 10, 2006 2:08 pm
by $var
i get it now,
str_replace($search, $replace, $_POST["solution"]);
but you can search a few things, and replace them appropriately, as long as they are in matching order in an array?
Posted: Fri Nov 10, 2006 3:00 pm
by feyd
I'm not sure what you're asking. You are allowed to pass arrays.
Posted: Fri Nov 10, 2006 3:50 pm
by $var
hmm... someone else told me to do this... and it sorta work:
Code: Select all
$search = array("'", "<br />");
$replace = array("'", "\n");
$solution = str_replace($search, $replace, $_POST["solution"]);
i think something else may be wrong, because i'm still getting a syntax no-no, but, the echo appears correct.