Explode function usage analysis in PHP, Phpexplode function Usage _php Tutorial

Source: Internet
Author: User

Explode function usage analysis in PHP, Phpexplode function usage


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:
Copy the Code code as follows: $explode = "AAA,BBB,CCC,DDD,EXPLODE,JJJJ";

$array = Explode (', ', $explode);

Print_r ($array);
/*
Result is
Array
(
[0] = AAA
[1] = BBB
[2] = = CCC
[3] = DDD
[4] = explode
[5] = 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:
Copy the Code code as follows: $file = "Www.jb51.net.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.

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/912289.html www.bkjia.com true http://www.bkjia.com/PHPjc/912289.html techarticle Explode function usage analysis in PHP, Phpexplode function Usage This paper analyzes the usage of explode function in PHP. Share to everyone for your reference. as follows: Explode (string separator,...

  • 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.