ereg_replace()
ereg_replace() function is used to replace regular expression case sensitive.
Syntax of ereg_replace() is:
string ereg_replace ( string $pattern , string $replacement , string $string ) |
It scans string to match pattern, and then replaces the text with replacement. If no string found then it will be returned unchanged.
E.g of ereg_replace() is:
<?php
$lastname = 'Singh';
$string = "This is pankaj kumar.";
$string = ereg_replace('kumar', $lastname, $string);
echo $string;
/* Output: 'This is pankaj Singh.' */
?>
eregi_replace()
eregi_replace() function is used to replace regular expression case insensitive.
Syntax of eregi_replace() is:
string eregi_replace ( string $pattern , string $replacement , string $string ) |
This is same as ereg_replace(), but it ignores the case sensitive when matching the strings.
E.g of eregi_replace() is:
<?php
$string = "Hi this is pankaj.";
print "Output :" .
eregi_replace("PANKAJ", "Kumar", $string);
/* Output: 'Hi this is Kumar.' */
?>
0 Comment(s)