11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 9 • STRINGS AND REGULAR EXPRESSIONSwww.it-ebooks.infoIf occurrence is not found in str, the original string is returned unmodified. If the optionalparameter count is defined, only count occurrences found in str will be replaced.This function is ideal for hiding e-mail addresses from automated e-mail address retrievalprograms:This returns the following:Contact the author of this article at jason(at)example.com.The function str_ireplace() operates identically to str_replace(), except that it is capable ofexecuting a case-insensitive search.Retrieving Part of a StringThe strstr() function returns the remainder of a string beginning with the first occurrence of apredefined string. Its prototype follows:string strstr(string str, string occurrence [, bool before_needle])The optional before_needle parameter modifies the behavior of strstr(), causing the function toinstead return the part of the string which is found before the first occurrence.This example uses the function in conjunction with the ltrim() function to retrieve the domainname of an e-mail address:This returns the following:example.comReturning Part of a String Based on Predefined OffsetsThe substr() function returns the part of a string located between a predefined starting offset and lengthpositions. Its prototype follows:string substr(string str, int start [, int length])220

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!