位置: 编程技术 - 正文

PHP:spliti()的用法_Regex正则函数(php str split)

编辑:rootadmin
spliti

推荐整理分享PHP:spliti()的用法_Regex正则函数(php str split),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:php split,php splice,php splfileobject,phpstr_split,php中split,php str split,phpstr_split,php splice,内容如对您有帮助,希望把文章链接给更多的朋友!

(PHP 4 >= 4.0.1, PHP 5)

spliti — 用正则表达式不区分大小写将字符串分割到数组中

说明 array spliti ( string $pattern , string $string [, int $limit = -1 ] )

用正则表达式将一个 string 分割成数组。

本函数和 split() 相同,只除了在匹配字母字符时忽略大小写的区别。

Warning

自 PHP 5.3.0起,已经废弃此函数。强烈建议不要应用此函数 。

参数

pattern

大小写不敏感的正则表达式。

If you want to split on any of the characters which are considered special by regular expressions, you&#;ll need to escape them first. If you think spliti() (or any other regex function, for that matter) is doing something weird, please read the file regex.7, included in the regex/ subdirectory of the PHP distribution. It&#;s in manpage format, so you&#;ll want to do something along the lines of man /usr/local/src/regex/regex.7 in order to read it.

string PHP:spliti()的用法_Regex正则函数(php str split)

输入的字符。

limit

如果设置了 limit,返回的数组最多会包含 limit 个元素,最后一个元素包含了剩下的全部 string。

返回值

Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the case insensitive regular expression pattern.

If there are n occurrences of pattern, the returned array will contain n+1 items. For example, if there is no occurrence of pattern, an array with only one element will be returned. Of course, this is also true if string is empty. If an error occurs, spliti() returns FALSE.

范例

本例用 &#;a&#; 做分隔符来分割一个字符串:

Example #1 spliti() 例子

<?php$string="aBBBaCCCADDDaEEEaGGGA";$chunks=spliti("a",$string,5);print_r($chunks);?>

以上例程会输出:

注释

Note:

在 PHP 5.3.0中,已放弃使用 regex 扩展而建议使用 PCRE 扩展。调用此函数将会发出E_DEPRECATED 通知。参见“差异列表”可帮助你转为使用 PCRE。

参见

preg_split() - 通过一个正则表达式分隔字符串 split() - 用正则表达式将字符串分割到数组中 explode() - 使用一个字符串分割另一个字符串 implode() - 将一个一维数组的值转化为字符串

PHP:ereg_replace()的用法_Regex正则函数 ereg_replace(PHP4,PHP5)ereg_replace正则表达式替换说明stringereg_replace(string$pattern,string$replacement,string$string)本函数在string中扫描与pattern匹配的部分,并将其替换

PHP:preg_replace()的用法_PCRE正则函数 preg_replace(PHP4,PHP5)preg_replace执行一个正则表达式的搜索和替换说明mixedpreg_replace(mixed$pattern,mixed$replacement,mixed$subject[,int$limit=-1[,int&$count]])搜索subject中匹配

PHP:preg_match()的用法_PCRE正则函数 preg_match(PHP4,PHP5)preg_match执行一个正则表达式匹配说明intpreg_match(string$pattern,string$subject[,array&$matches[,int$flags=0[,int$offset=0]]])搜索subject与pattern给定的正则

本文链接地址:https://www.jiuchutong.com/biancheng/279882.html 转载请保留说明!

上一篇:PHP:eregi_replace()的用法_Regex正则函数

下一篇:PHP:ereg_replace()的用法_Regex正则函数

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络