submitted by: Guest
PHP: string replace
find and replace pattern in a string.
code snippet:
<?php
// STRING REPLACE - find and replace inside a string
$bodytext="one two three four five seven";
echo $bodytext;
$searchtext="seven";
$replacetext="six";
$bodytext = ereg_replace ($bodytext, $searchtext, $replacetext);
echo $bodytext;
?>
sample output:
one two three four five six



