php substr_replace code example
Example 1: php replace
str_replace ($search, $replace, $subject);
Example 2: php replace string within string
$new_string = str_replace( $take_out, $put_in, $string);
Example 3: str_replace php
echo str_replace("worss","world","Hello worss in PHP!!");
Example 4: php substr_replace
\n";
/* These two examples replace all of $var with 'bob'. */
echo substr_replace($var, 'bob', 0) . "
\n";
echo substr_replace($var, 'bob', 0, strlen($var)) . "
\n";
/* Insert 'bob' right at the beginning of $var. */
echo substr_replace($var, 'bob', 0, 0) . "
\n";
/* These next two replace 'MNRPQR' in $var with 'bob'. */
echo substr_replace($var, 'bob', 10, -1) . "
\n";
echo substr_replace($var, 'bob', -7, -1) . "
\n";
/* Delete 'MNRPQR' from $var. */
echo substr_replace($var, '', 10, -1) . "
\n";
?>
Example 5: php substr_replace
substr_replace(string,replacement,start,length)