PHP implode() Function

PHP implode() Function is used to join array elements into string.

Syntax :

implode(separator,array);

PHP implode() Function returns string with separator between two array elements.

Parameter Values,
 

PHP implode() Function
Parameter Description
separator Optional. Join array elements with separator string.
Default value for separator is an empty string.
array Required. The array to join to a string.

Let's see below example to understand implode() Function in details.

Example :

<?php
$arr = array('Learn','php','implode','function','by','aryatechno');
print_r($arr);
echo "<br> Join array element without separator :".implode($arr)."<br>";
echo "<br> Join array element by space :".implode(" ",$arr)."<br>";
echo "<br> Join array element by dash:".implode("-",$arr)."<br>";
echo "<br> Join array element by semicolon:".implode(";",$arr)."<br>";
echo "<br> Join array element by comma:".implode(";",$arr)."<br>";

?>

Output :

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

67450