Read about difference between split and explode in php, The latest news, videos, and discussion topics about difference between split and explode in php from alibabacloud.com
As we all know, both explode and split can convert strings into arrays through specific characters in php. so why are there two functions of explode and split in the same way, so what is the difference between explode and split? let's take a look at
First, the preface
This is done because the two functions are similar in that they are converting strings into groups.
Second, explode
As can be seen from the example below, the resulting array is in a corresponding order.
$pizza = "Piece1
At one level, the explode and split functions in php are used to split characters into arrays. However, there are still differences between explode and split, next I will introduce it to you. At one level, the explode and split functions in php are
This example describes how PHP obtains the number of days and date arrays by month. Share to everyone for reference, as follows: function Get_day ($date) {$tem = explode ('-', $date);//cut date to get year and month $year = $tem [' 0 ']; $month =
At one level, the explode and split functions in php are used to split characters into arrays. However, there are still differences between explode and split, next I will introduce it to you.
First, let's take a look at the definitions of the two
Both the PHP strtok () function and the explode () function can be used to split a string, but there are some differences between the two, and the Strtok () function can control the rhythm of the explode (), and this article describes in detail the
Differences between explode and split in php. First, let's take a look at the definition of the two methods: Function prototype: arraysplit (string $ pattern, string $ string [, int $ limit]) function prototype: arrayexplode (string $ separator,
Objective
This is done because the two functions are similar in that they are converting strings into groups.
Explode
As can be seen from the example below, the resulting array is in a corresponding order.
The code is as follows
First look at the definition of two methods:
Function prototype: Array split (String $pattern, string $string [, int $limit])
Function prototype: array explode (string $separator, string $string [, int $limit])
At first glance there is no
We all know that PHP explode () function is to divide a string into arrays. This return value is an array of strings, so today we'll show you how to use the Explode function to split a string into an instance of an array!
Using the explode function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.