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.