how to implode array


The implode() function returns a string from the elements of an array or Join array elements with a string.

Key Concept :

  •  The implode() function accept its parameters in either order.
  •  The separator parameter of implode() is optional. However, it is recommended to always use two parameters for backwards compatibility.
  •  This function is binary-safe.

Syntax :

implode(separator,array)

separator :-  Optional. Specifies what to put between the array elements. Default is “” (an empty string).
array  :- Required. The array to join to a string.

Example for implode() function:

<!DOCTYPE html>
<html>
<body>

<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
?>

</body>
</html>

Output : Hello World! Beautiful Day!

Thanks for reading !…..