In PHP, you can use the first parameter of the implode() function to set no delimiter. The first parameter of the function is used to specify the content placed between the array elements. The default is an empty string. , you can also set the first parameter to empty, the syntax is "implode (array)" or "implode ("", array)".
The operating environment of this article: Windows 10 system, PHP version 8.1, Dell G3 computer.
implode() function returns a string composed of array elements.
The syntax is:
implode(separator,array)
The parameters are expressed as follows:
separator is optional. Specifies what is placed between array elements. Default is "" (empty string).
array required. Arrays to be combined into strings.
Set the parameter separator to empty or to an empty string to return results without separators.
The example is as follows:
<?php $arr = array('1','2','3','4'); echo implode($arr)."<br>"; echo implode("",$arr)."<br>"; echo implode("-",$arr); ?>
Output result:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to set implode in php without separator. For more information, please follow other related articles on the PHP Chinese website!