Home >Backend Development >PHP Tutorial >The difference between PHP function implode() and explode() function_PHP tutorial
In previous articles, we have introduced you to the specific usage of the explode() function. When we encounter the PHP function implode() combines the array elements into a string.
implode(separator,array)
separator optional. Specifies what is placed between array elements. Default is "" (empty string).
array required. Arrays to be combined into strings.
Although the separator parameter is optional. However, for backward compatibility, it is recommended that you use two parameters.
Example of PHP function implode()
<ol class="dp-xml"><li class="alt"><span><span class="tag"><?</span><span class="tag-name">php</span><span> </span></span></li><li><span>$</span><span class="attribute">arr</span><span> = </span><span class="attribute-value">array</span><span>('Hello','World!','Beautiful','Day!'); </span></li><li class="alt"><span>echo implode(" ",$arr); </span></li><li><span class="tag">?></span><span> </span></span></li></ol>
Output:
Hello World! Beautiful Day!
The above code example is a demonstration of the specific implementation function of the PHP function implode().