Implode() and Explode() Function in PHP

implode()

The implode() function returns a string from the array.

$array = array('1','2','3','4','5');
echo implode(" ", $array);

//Output
1,2,3,4,5

explode()

$string = "1,2,3,4,5";
print_r(explode(",", $string));

//Output
Array ([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5)

Leave a Reply

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