I am trying to use the preg_replace function and I'm getting this error: "Delimiter must not be alphanumeric or backslash...". What have I missed?
$row['Word'] = about; $row['Abv'] = abt; $string = "What is this all about";
$newstring = preg_replace($row['Word'],$row['Abv'],$string);
Never mind, I figured it out.
Anyone looking might need to know that the patern and replacement must have a \ to start and a $ to end with.
ie. $newstring = preg_replace("\$row['Word']$","\$row['Abv']$",$string); // This one worked.
I was able to get the error to go away, however I still have a problem. It doesn't seem to be replacing anything at all, what is returned is the same string I entered intot it.
Help.
Thanks John
$newstring = preg_replace("/".$row['Word']."$/",$row['Abv'],$string)