Home > Article > Backend Development > Detailed explanation of php implode() function example
What is the function of php implode() function?
The implode() function in php returns a string composed of array elements. It has the opposite effect to the php explode() function. php explode() The function is: split a string using another string and return an array of strings.
Understanding the role of the php implode() function, let’s take a look at the syntax and examples of the php implode() function
Grammar
implode(separator,array)
Parameter details:
Description | |
---|---|
separator | Optional. Specifies what is placed between array elements. Default is "" (empty string).|
array | Required. Arrays to be combined into strings.
Example
Use different characters to separate array elements, the code is as follows:<?php $arr = array('Hello','World!','Beautiful','Day!'); echo implode(" ",$arr)."<br>"; echo implode("+",$arr)."<br>"; echo implode("-",$arr)."<br>"; echo implode("X",$arr); ?>Code running result:
【Recommended related articles】1.
php explode() function example detailed explanation
2.Use of php explode() function method
The above is the detailed content of Detailed explanation of php implode() function example. For more information, please follow other related articles on the PHP Chinese website!