PHP can divide the string into an array, and also can be connected to the string, and the exact connection of the array elements into a string, with these two functions we can be between the array and the string of free conversion, see the example of the text below.
Implode () Join function:
This function implements connecting an array element to a string, before we give it two arguments, one is the connector that is going to be connected to the array
Note is a one-dimensional array oh, the multidimensional Small series is seldom used, but we can try.
Example:
<?php
$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 is to divide the string into the array, we still give it two parameters, one is the delimiter is going to be split string
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>";
Print_r ($array);
= = = The result is an array of the above example definitions, and the small part here is not written.
?>
PHP connection function implode () and split explode ()