- str_replace: documentation ( source)
<?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;
?>