The explode () function in PHP is to split another string with one string and return an array of strings. The implode () function returns a string that is composed of array elements. The two functions are between the strings and the array
function of mutual conversion.
First, from the usage point of view, one is to concatenate the array elements into a string, one to divide the string into the array. So it's different from the usage.
Then there is the difference in the receiving parameters, explode () because of historical reasons can not receive two parameter order, must ensure that the separator parameter before the string parameter;
Implode () can accept two parameter sequences.
Example
Implode () Join function:
<?php$array = Array (' a ' = = 1, ' B ' =>2, ' C ' =>3, ' d ' =>4); $string = Implode ("-", $array); echo $string;? >
With running results such as:
Explode () Split function:
Note that this delimiter is present in the string, and we still use the above results as an example.
<?php$string = "1-2-3-4"; $array = Explode ("-", $string); echo "<pre>";p Rint_r ($array);? >
Code Run Result:
The implode () function and the scene used by the explode () function:
The explode () method is often used to enter multiple options, separated by a specific delimiter, to convert an array.
Implode () converts an array to a string, when constructing an SQL statement, for example
Insert into table (COL1,COL2,COL3) VALUES (' value1 ', ' value2 ', ' value3 ')
This makes it easier to construct.