Analysis of usage of explode function in php, usage of phpexplode function
This article analyzes the usage of explode function in PHP with examples. Share it with everyone for your reference. The details are as follows:
explode(string separator,string string [,int limit])
Separator is an empty string (""), explode() will return FALSE, if the value contained in separator is not found in string, explode() will return an array containing a single element of string.
explode example 1, the code is as follows:
Copy code The code is as follows:
$explode = "aaa,bbb,ccc,ddd,explode,jjjj";
$array = explode( ',' ,$explode );
print_r($array);
/*
//The result is
Array
(
[0] => aaa
[1] => bbb
[2] => ccc
[3] => ddd
[4] => explode
[5] => jjjj
)
*/
When we process dates or obtain file extensions, we can use the explode function and the end function. Let’s look at the example below. The code is as follows:
Copy code The code is as follows:
$file ="www.jb51.net.gif";
$extArray = explode( '.' ,$file );
$ext = end($extArray);
echo $ext;
//The output value is .gif
The error messages that appear when using some functions are: Note: Separator cannot be an empty string. Note: The separator cannot be an empty string, and the string to be split is empty.
Definition and Usage does not use the split function. It may be that the split character you set does not exist.
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/912289.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/912289.htmlTechArticleAnalysis of the usage of the explode function in php, usage of the phpexplode function. This article analyzes the usage of the explode function in php with examples. Share it with everyone for your reference. The details are as follows: explode(string separator,...