gongzhonghao.png
扫码关注我们
最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

php字符串分割函数用法实例_php技巧

来源:http://erdangjiade.com/topic/130066.html 你好,世界。 2017-10-04 21:03浏览(20)

本文实例讲述了php字符串分割函数用法。分享给大家供大家参考。具体分析如下:

php中explode 和 split 函数用来分割字符串。

explode函数语法如下

explode(substring, string)

explode函数通过子字符串进行分割,效率比split要高 split函数语法如下

split(pattern, string)

split通过正则表达式对字符串进行分割,效率相对explode要低,但是功能强大

<?php 
$list = explode("_","php_strting_function.html");
print("explode() returns:n");
print_r($list);
$list = split("[_.]","php_strting_function.html");
print("split() returns:n");
print_r($list);
?>

输出结果如下:

explode() returns:
Array
(
[0] => php
[1] => strting
[2] => function.html
)

split() returns:
Array
(
[0] => php
[1] => strting
[2] => function
[3] => html
)

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

评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2