php explode函数怎样用?
php explode()函数 语法
作用:把字符串打散为数组
语法:
explode(separator,string,limit)
参数:
separator 必须。划定在那里支解字符串。
string 必须。要支解的字符串。
limit 可选。划定所返回的数组元素的数量。能够的值:大于 0 - 返回包括最多 limit 个元素的数组,小于 0 - 返回包括除了末了的 -limit 个元素之外的一切元素的数组,0 - 返回包括一个元素的数组
申明:
把字符串打散为数组。"separator" 参数不能是空字符串。该函数是二进制平安的。
php explode()函数运用示例1:
<?php $str = "Hello world. I'm study in ki4.cn!"; print_r (explode(".",$str)); ?>
输出:
Array ( [0] => Hello world [1] => I'm study in php [2] => cn! )
php explode()函数运用示例2:
<?php $arr = "Learning PHP is a good choice"; print_r(explode(" ", $arr)); ?>
输出:
Array ( [0] => Learning [1] => PHP [2] => is [3] => a [4] => good [5] => choice )
本篇文章就是关于PHP explode函数的引见,愿望对须要的朋侪有所协助!
以上就是php explode函数怎样用的细致内容,更多请关注ki4网别的相干文章!