This article analyzes the usage of explode function in PHP. Share to everyone for your reference. Specifically 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, explode () returns an array containing a single element of string.
Explode instance one, the code is as follows:
Copy 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 with the End function when we process the date or get the file name extension, the following example, the code is as follows:
Copy Code code as follows:
$file = "Www.jb51.net.gif";
$extArray = Explode ('. ', $file);
$ext = End ($extArray);
Echo $ext;
The output value is. gif
Some of the error prompts that appear with some functions are: Note:separator cannot be a empty string. Note: The delimiter cannot be a null string, and the string to be split is empty.
The Definition and Usage do not use a split function, possibly the split character you set does not exist.
I hope this article will help you with your PHP program design.