When I try to make a user defined function using str_replace it has no effect. Components of the same code work perfectly when not in a user defined function. The following shows a simple representation of my problem.
<?php
function replacelist($thetext) {
$seachfor = array("crackers","soup");
$replacewith = array("shapes","stew");
$newtext = str_replace($searchfor, $replacewith, $thetext);
return $newtext." - plus some test text";
}
?>
<?php
$mytext="Animal crackers in my soup";
$newphrase = replacelist($mytext);
echo $newphrase;
?>
The above results in
Animal crackers in my soup - plus some test text
Any help gratefully received.
Thanks David