function prototypes for explode ():Array explode (string separator,string input [, int limit]); [, int limit] is a means of optional
Parameters
Description
Separator
Necessary. Specifies where to split the string.
String
Necessary. The string to split.
Limit
Optional. Specifies the maximum number of array elements that are retu
PHP Character Segmentation explode,split,preg_split Performance Comparison
Three functions are used to split a string, and several experiments are performed to compare the performance.
1. Comparison between explode and split
are split with characters and executed 10 times
Code:
for ($num =0; $num
Results:
Explode takes 0.009193Explode takes 0.007066Explode takes
In PHP, strings and arrays are transferred to each otherSplitting a string into an array explode ()--(split in other languages)Concatenate an array into a string implode ()PHP$test= ' I am Tommy.huang '; $result 1=Explode(‘ ‘,$test); Print_r($result 1); Echo' ; $result 2=Explode(‘,‘,$test); Print_r($result 2); Echo' ; $test _array1=Array( ' Apple ', ' pear
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
Copy Code
$pizza = "Piece1 piece2 piece3 piece4 piece5 piece6";$pieces = Explode ("", $pizza);echo $pieces [0]; Piece1echo $pieces [1]; Piece2Example
Definition and usageThe explode () function splits the string into arrays.GrammarExplode (Separator,string,limit)
Parameters
Description
Separator
Necessary. Specifies where to split the string.
String
Necessary. The string to split.
Limit
Optional. Specifies the maximum number of array elements that are returned.
DescriptionThis function returns an array of st
Use of implode, explode, implodeexplode. The use of implode and explode. the implodeexplodeimplode function converts an array into a string, which is especially useful when combining SQL statements! For example, $ aarray (a, B, c); $ bimplode (, $ a implode, explode usage, implodeexplode
The implode function converts an array into a string, which is used to co
This article mainly introduces the usage analysis of substr () and explode () functions in PHP, and describes in detail how substr () and explode () functions process strings in the form of instances, it is a function that is frequently used in string operations and has some practical value. For more information about how to use substr () and explode () functions
Today, there is an urgent bug, that is the background after configuring the whitelist, the mobile app is not valid, still display content. After receiving the mail, then went through the process, found that the background configuration whitelist is configured in the textarea, one line, and then in the code to see, using the Explode function segmentation, where the delimiter is \ r \ n. This article mainly share with you the method that PHP uses Preg_s
First, preface
The reason for doing this is because the two functions are very similar in that they are converting strings into groups.
Second, explode
As can be seen from the following example, the resulting array is in the corresponding order.
$pizza = "Piece1 piece2 piece3 piece4 piece5 piece6"; $pieces = Explode ("", $pizza); Echo $pieces [0]; Piece1echo $pieces [1]; PIECE2//Example 2$data = "foo:*:102
Php string splitting function explode instance code. Arrayexplode (string $ separator, string $ string [, int $ limit]) This function has three parameters. The first parameter $ separator sets a delimiter (string ). The second parameter $ string specifies the array explode (string $ separator, string $ string [, int $ limit]) to be operated.
This function has three parameters. The first parameter $ separat
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, string $ string first, let's look at the definitions of the two methods:
Function prototype: array split (string $ pattern, string $ string [, int $ limit])
Function prototype: array
$STR = ' array 1, array 2, array 3, array 4 ';
$array = Explode (', ', $str); Depositing a regular string into an array
The explode () function splits the string into arrays.
GrammarExplode (separator,string,limit) parameter descriptionSeparator required. Specifies where to split the string.string is required. The string to split.Limit is optional. Specifies the maximum number of array elements that are re
Use "str_split" to separate strings. The advantage is that a space is also used as an array element. In my previous example, the previous string contains two spaces, and the next string has only one space. However, the output displays the same information. It can also be split by other separators, such as "explode" or "preg_split ",
Use "str_split" to separate strings. The advantage is that a space is also used as an array element. In my previous exam
Str_replace string Match substitution$keyword= "ASP php,jsp";$keyword=Str_replace(" "," ",$keyword); Echo $keyword;Echo";$keyword=Str_replace(" ",",",$keyword);Echo $keyword;Echo";$keyarr=Explode(‘,‘,$keyword); for($index= 0;$indexCount($keyarr);$index++) { $WHERESQL. = "and (Arc.title like '%$keyarr[$index]% ' Or arc.keywords like '%$keyarr[$index]%‘) ";} Echo $WHERESQL;Explode splitting a string by an
Phpsubstr (), explode (), strrev (). Substr (str, start, length); example: substr (php Tutorial isverygoodlanguage,); output is isve; when startstr length, return (); substr (phpisverygoodlanguage, 26, 5); s substr (str, start, length );
Example: substr ('php tutorial is very good language );
Output is ve;
If the length of start> str is returned ();
Substr ('php is very good language );
Substr ('php is very good language ', 4 );
Output as (blank)
Out
Explode () function: Splits the array by splitting another string with one string. The following article introduces you to the use of PHP explode () function cut string array, the need for friends can refer to the following
Explode () function: Splits the array by splitting another string with one string.
For example:
String
$pizza = "1th 2nd 3rd 4th 5th 6
This article mainly introduces PHP substr () and explode () function usage analysis, in the form of an instance of the substr () and explode () function to deal with the string of skills, is the use of high frequency function in string operation, has a certain practical value, A friend you need can refer to the following
This example describes the use of substr () and
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.