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