php中explode函数用法分析_PHP
May 31, 2016 pm 07:27 PM本文实例分析了php中explode函数用法。分享给大家供大家参考。具体如下:
explode(string separator,string string [,int limit])
separator 为空字符串(""),explode() 将返回 FALSE,如果 separator 所包含的值在 string 中找不到,那么 explode() 将返回包含 string 单个元素的数组.
explode实例一,代码如下:
代码如下:
$explode = "aaa,bbb,ccc,ddd,explode,jjjj";
$array = explode( ',' ,$explode );
print_r($array);
/*
//结果为
Array
(
[0] => aaa
[1] => bbb
[2] => ccc
[3] => ddd
[4] => explode
[5] => jjjj
)
*/
我们在处理日期或取得文件扩展名时就可以用explode函数与end函数操作,下面来看实例,代码如下:
代码如下:
$file ="www.bitsCN.com.gif";
$extArray = explode( '.' ,$file );
$ext = end($extArray);
echo $ext;
//输出值为.gif
使用些函数出现的错误提示有:Note: Separator cannot be an empty string.注意:分割符不可以是空字符串,要分割的字符串为空.
Definition and Usage 未使用分割函数,可能是你设置的分割字符不存在.
希望本文所述对大家的PHP程序设计有所帮助。

Article chaud

Outils chauds Tags

Article chaud

Tags d'article chaud

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds

Guide d'installation et de mise à niveau de PHP 8.4 pour Ubuntu et Debian

Comment configurer Visual Studio Code (VS Code) pour le développement PHP
