split vs. explode in php

后端 未结 4 1312
一个人的身影
一个人的身影 2021-02-06 22:13

What is the difference between explode and split in php?

相关标签:
4条回答
  • 2021-02-06 22:35

    explode is generally faster than split ; but its not multibyte character safe.

    We will use explode when we are absolutely guaranteed that our input is in single-byte character sets such as ISO-8859-1, and split when we are dealing with user input.

    0 讨论(0)
  • 2021-02-06 22:35

    Both split and explode function splits the string into the array but split is used to split a string using regular expression while explode is used to split a string using another string.

    0 讨论(0)
  • 2021-02-06 22:53

    split uses regular expressions, while explode works with delimiter characters. Using split is discouraged, because it become deprecated in PHP 5.3.

    0 讨论(0)
  • 2021-02-06 22:55

    explode splits strings.

    split also does this, except it has support for splitting using regular expressions.

    preg_split also does this and is 25-50% faster and has support for (IMO) much more extensible Perl-compatible regular expressions.

    0 讨论(0)
提交回复
热议问题