Concatenating array elements in PHP using implode() function

PHP's built-in implode() function concatenates array elements into a string using a specified delimiter. It returns a string resulting from joining the array elements separated by the provided string. To use the implode() function, you should pass two arguments: the string you want to use as the delimiter and the array you want to concatenate. If you pass only one argument (an array), PHP will automatically use the empty string as the delimiter. The implode() function does not change the original array. In this PHP Implode Example, we concatenate array elements using a comma as a separator. Click Execute to run the PHP Implode Example online and see the result.
Concatenating array elements in PHP using implode() function Execute
<?php
$fruits = array("apple", "banana", "cherry");
$fruitString = implode(", ", $fruits);
echo $fruitString;
?>
Updated: Viewed: 58 times