PHP Function: Built-in Functions part 10

Regular Expression Functions
ereg_replace() and eregi_replace()
The ereg_replace() and eregi_replace() functions replace instances of a pattern within a string and return the new string. The ereg_replace() function performs a clase-sensitive match, and eregi_replace() performs a case-insensitive match. Here is the syntax for both functions:
ereg_replace(pattern, replacement, string);
eregi_replace(pattern, replacement, string);
For example, you would use the following code to replace “ASP” with “PHP” in the string “I really love programming in ASP”:
$old_string = "I really love programming in ASP";
$new_string = ereg_replace("ASP", "PHP", $old_string);
echo "$new_string";
If “ASP” is mixed case, such as “aSp”, use the eregi_replace() function:
$old_string = "I really love programmin in aSp";
$new_string = eregi_replace("ASP", "PHP", $old_string);
echo "$new_string";
split()
The split() function splits a string into an array using a certain separator (comma, colon, semicolon, and so on). Its syntax is
split(pattern, string, [limit]);
If limit is specified, the split() function stops at the named position–for example, at the tenth value in a common-delimited list. Next php function: Built-in Functions part 11
