Heim  >  Artikel  >  Backend-Entwicklung  >  php中explode函数用法分析,phpexplode函数用法_PHP教程

php中explode函数用法分析,phpexplode函数用法_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:14:01787Durchsuche

php中explode函数用法分析,phpexplode函数用法

本文实例分析了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.jb51.net.gif";
 
 $extArray = explode( '.' ,$file );
 $ext = end($extArray);
 echo $ext;
 
//输出值为.gif

使用些函数出现的错误提示有:Note: Separator cannot be an empty string.注意:分割符不可以是空字符串,要分割的字符串为空.

Definition and Usage 未使用分割函数,可能是你设置的分割字符不存在.

希望本文所述对大家的PHP程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/912289.htmlTechArticlephp中explode函数用法分析,phpexplode函数用法 本文实例分析了php中explode函数用法。分享给大家供大家参考。具体如下: explode(string separator,...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn