Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

string sql_regcase(string regular_expression)


The sql_regcase function translates a case-sensitive regular expression into a case-
insensitive regular expression. This is unnecessary for use with PHP's built-in regular
expression functions but can be useful when creating regular expressions for external
programs such as databases.


<?


//print [Mm][Oo][Zz][Ii][Ll][Ll][Aa]
print(sql_regcase("Mozilla"));
?>


string str_replace(string target, string replacement, string
text)


The str_replace function attempts to replace all occurrences of target in text
with replacement. This function is safe for replacing strings in binary data. It's also a
much faster alternative to ereg_replace. Note that str_replace is case sensitive.


<?


$text = "Search results with keywords
highlighted.";
print(str_replace("keywords", "keywords/B>",
$text));
?>


string strip_tags(string text, string ignore)


The strip_tags function attempts to remove all SGML tags from the text
argument. This includes HTML and PHP tags. The optional ignore argument may
contain tags to be left alone. This function uses the same algorithm used by fgetss. If
you want to preserve tags, you may wish to use htmlentities.


<?


//create some test text
$text = "

Paragraph One

Paragraph Two";


//strip out all tags except paragraph and break
print(strip_tags($text, "


"));

Free download pdf