About split () and explode () in php ()

Source: Internet
Author: User
First, paste the php code and look at the two functions: & amp; lt ;? Php $ email = 'phpddt1990 @ 163.com '; $ arr = split (' \. | @ ', $ email); print_r ($ ar

First, paste the php code and look at the two functions:


 

 

At least we can see from the above:

The explode function can only be separated by characters. However, the split function uses regular expressions. of course, the split function can be used to handle some complex string analysis problems. Explode requires certain rules, but the execution efficiency is higher!

It is worth noting that the first piece of code has a small problem: the following error will be reported:

Deprecated: Function split () is deprecated in F: \ web \ zend \ exercise \ test. php on line4

This is because the split () function after php5.3 is not recommended,

POSIX style cannot be used, and the recommended Function (PCRE) is as follows:

* POSIX → PCRE
* Ereg_replace () → preg_replace ()
* Ereg () → preg_match ()
* Eregi_replace () → preg_replace ()
* Eregi () → preg_match ()
* Split () → preg_split ()
* Spliti () → preg_split ()
* SQL _regcase () → No equivalent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.