This article provides a detailed analysis of the php connection function implode and split explode. For more information about php, see the following, many php trainees always ask the following question: What is the php connection function implode?
Php can split the string into an array. after turning it over, it can also connect the array to a string. Specifically, it can connect the array element to a string, with these two functions, we can freely convert between arrays and strings. let's look at the example in the text below.
Implode () connection function:
This function concatenates an array element into a string. before the connection, we need to provide two parameters. one is the connector and the other is the array to be connected.
Note that it is a one-dimensional array, which is rarely used in multi-dimensional editing, but you can try it.
Example:
The code is as follows:
$ Array = array ('a' => 1, 'B' => 2, 'C' => 3, 'D' => 4 );
$ String = implode ("-", $ array)
Echo $ string;
// ==== The result is: 1-2-3-4;
?>
Explode () split function:
This function separates strings into arrays. we still give them two parameters. one is the separator and the other is the string to be split.
Note that this separator exists in the string. we still use the above result as an example.
The code is as follows:
$ String = "1-2-3-4 ";
$ Array = explode ("-", $ string );
Echo"
";
Print_r ($ array );
// ==== The result is the array defined in the preceding example.
?>