1$array = array('banana', 'strawberry', 'apple');
2comma_separated = implode(",", $array);
3echo comma_separated; // banana,strawberry,apple
1$arr = array('Hello','World!','Beautiful','Day!');
2echo implode(" ",$arr);
3// Outputs: 'Hello World! Beautiful Day!'
1$colors = array("red","blue","green");
2$colorsCSV= "'".implode("','",$colors)."'";
3//$colorsCSV: 'red','blue','green'
1$arr = ['Thor','Captain America','Iron Man'];
2echo implode(', ',$arr);
3// "Thor, Captain America, Iron Man"
1// from PHP 8.0 (order parameters has been changed)
2
3$arr = array('Hello','World!','Beautiful','Day!');
4
5echo implode($arr, " ");