$array = array('banana', 'strawberry', 'apple');
comma_separated = implode(",", $array);
echo comma_separated; // banana,strawberry,apple
$values = array_map('array_pop', $array);
$imploded = implode(',', $values);
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
// Outputs: 'Hello World! Beautiful Day!'
<?php
$arr = array('cat','dog','elephent');
// it will convert array to string
$str = implode(', ',$arr);
echo $str;
?>
$colors = array("red","blue","green");
$colorsCSV= "'".implode("','",$colors)."'";
//$colorsCSV: 'red','blue','green'
$arr = ['Thor','Captain America','Iron Man'];
echo implode(', ',$arr);
// "Thor, Captain America, Iron Man"
$users = [
'user1' => 'user1@example.com',
'user2' => 'user2@example.com'
];
echo implode(', ',$users);
// "user1@example.com, user2@example.com"
// from PHP 8.0 (order parameters has been changed)
$arr = array('Hello','World!','Beautiful','Day!');
echo implode($arr, " ");
implode(",", $array)