Ereg_replace
(PHP3, PHP4)
Ereg_replace---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Formal expression substitution
Syntax: String ereg_replace (string pattern, string replacement, string string)
Description:
This function scans the string to compare with the pattern, and then replaces the replacement text with the.
This function returns the modified string and returns the original string if it is not.
If pattern contains a partial string of parentheses, replacement can contain a partial string of "\ Number", which will be substituted with a partial string in the parentheses. \\0 will produce the contents of the entire string, using up to nine partial strings, in which case it will be evaluated with open parentheses.
If no comparison is found in a string, the unchanged string is returned.
The following example cuts off the string and displays three times "This is a test":
<?php
$string = "This is a test";
Echo ereg_replace (' is ', ' was ', $string);
Echo ereg_replace ("() is", "\\1was", $string);
Echo Ereg_replace (() is), "\\2was", $string);
?>
One place to note is that if you use an integer value in the parameter replacement, you may not get the result because ereg_replace () will interpret the number as the order (ordinal) value of the character and execute it, for example:
<?php
/* This is not work as expected. */
$num = 4;
$string = "This string super-delegates Loko words."
$string = ereg_replace (' Loko ', $num, $string);
Echo $string; /* Output: ' This string super-delegates words. '
/* This'll work. * * $num = ' 4 ';
$string = "This string super-delegates Loko words."
$string = ereg_replace (' Loko ', $num, $string);
Echo $string; /* Output: ' This string super-delegates 4 words. '
?>
Reference: Ereg () eregi () eregi_replace ()