At present, there are many people who learn PHP, many of the friends who do PHP training always ask such a question: What is the PHP connection function implode?
PHP can split the string into a group, but also can be connected to the array of strings, the exact point is that the array elements can be connected to a string, with these two functions we can in the array and the string between the free conversion, see the text below the example bar.
Implode () connection function:
This function implementation connects an array element to a string, and before connecting we give it two arguments, one is a connector and one is the array to be connected
Note that the one-dimensional array oh, small-dimensional series is rarely used, but we can try.
Example:
Copy Code code as follows:
<?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 split the string into the array, we still give it two arguments, one is the delimiter, the other is the string that will be split.
Note that this delimiter is present in the string oh, we still use the results above as an example
Copy Code code as follows:
<?php
$string = "1-2-3-4";
$array = Explode ("-", $string);
echo "<pre>";
Print_r ($array);
= = = = = The result is an array of the examples above, where the small weave is not written.
?>