split()和explode()有什么区别? [英] What is the difference between split() and explode()?

查看:172
本文介绍了split()和explode()有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

split() 的PHP手册说

The PHP manual for split() says

此功能已被 已弃用 PHP 5.3.0.依靠这个功能 强烈建议...使用explode() 代替.

This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged...Use explode() instead.

但是我找不到split()explode()之间的区别. join()尚未被弃用,那有什么用呢?

But I can't find a difference between split() and explode(). join() hasn't been deprecated, so what gives?

推荐答案

已被弃用,因为

  • explode()基本上更快,因为它不会基于正则表达式进行拆分,因此不必由正则表达式分析器分析字符串
  • preg_split()速度更快,并使用PCRE正则表达式进行正则表达式拆分
  • explode() is substantially faster because it doesn't split based on a regular expression, so the string doesn't have to be analyzed by the regex parser
  • preg_split() is faster and uses PCRE regular expressions for regex splits

join()implode()是彼此的别名,因此没有任何区别.

join() and implode() are aliases of each other and therefore don't have any differences.

这篇关于split()和explode()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆