The implode() or join() is a built-in function in PHP and it is used for creating a string by joining the elements or values of an array with a glue string like hyphen (-) or comma (,).
Syntax:
implode(separator,array)
separator – This parameter is Optional. It Specifies what to put between the array values or elements. Default is “” (an empty string).
array – This parameter is required. The array to join to a string.
Example:
<?php $array = array("HTML", "CSS", "PHP"); // Turning array into a string $str = implode(", ", $array); echo $str; // Outputs: HTML, CSS, PHP echo '<br>'; $str = implode(" - ", $array); echo $str; // Outputs: HTML - CSS - PHP ?>
Recent Comments