A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/3690495/split-vs-explode-in-php/3690516 below:

split vs. explode in php

Asked 14 years, 10 months ago

Viewed 45k times

What is the difference between explode and split in php?

David Refoua

3,65744 gold badges3434 silver badges5959 bronze badges

asked Sep 11, 2010 at 9:43

Tejas PatelTejas Patel

1,15833 gold badges1111 silver badges1717 bronze badges

1

explode splits strings.

split (replaced with mb_split in newer versions of PHP) 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 much more powerful Perl-compatible regular expressions.

answered Sep 11, 2010 at 9:49

amphetamachineamphetamachine

30.8k1212 gold badges6868 silver badges7474 bronze badges

1

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

answered Sep 11, 2010 at 9:46

tamasdtamasd

5,93333 gold badges2727 silver badges3131 bronze badges

2

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.

answered Sep 11, 2010 at 9:49

sushil bharwanisushil bharwani

30.3k3030 gold badges9898 silver badges130130 bronze badges

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.

answered Jul 25, 2017 at 6:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4