The use of PHP explode functions

Source: Internet
Author: User
Tags php explode
This article mainly introduces the usage of explode function in PHP, the example analyzes the application of explode function segmentation string and obtains the file suffix name, it has certain reference value, the need friend can refer to the following

This paper analyzes the usage of explode function in PHP. Share to everyone for your reference. Specific as follows:

Explode (string separator,string string [, int limit])

Separator is an empty string (""), Explode () returns FALSE, and if separator contains a value that is not found in string, then explode () returns an array containing a single element of string.

Explode instance one, the code is as follows:

The code is as follows:

$explode = "AAA,BBB,CCC,DDD,EXPLODE,JJJJ";  $array = Explode (', ', $explode);  Print_r ($array); /*/result for Array (     [0] = = AAA     [1] = BBB [     2] = = CCC     [3] = DDD     [4] = explode     [5] =&G T JJJJ) */

We can use the explode function and the end function to manipulate the date or to get the file name extension, as shown in the following example code:

The code is as follows:

$file = "Www.php.cnt.gif";   $extArray = Explode ('. ', $file);  $ext = End ($extArray);  echo $ext;  Output value is. gif

The error hints for using some functions are: Note:separator cannot is an empty string. Note: Delimiters cannot be empty strings, the string to be split is empty.

The Definition and usage does not use a split function, and it is possible that the split character you set does not exist.

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.