π This post is based on the content from coding.courses .
Definition and Usage
(PHP Version | 4+)
The join() function joins array elements into a string using a custom delimiter.
The join() function is an alias of the implode() function. It works identically to the implode() function.
This function returns a single string by joining each element of a given array with a specified delimiter.
Basic Example
$colors = [ 'red' , 'green' , 'blue' ]; $comma_separated = join ( ', ' , $colors ); // Join with a ', ' delimiter
echo $comma_separated ; // Output: 'red, green, blue'
Enter fullscreen mode
Exit fullscreen mode
Syntax
join ( string $separator , array $array ) : string
Enter fullscreen mode
Exit fullscreen mode
Parameters
# $separator
Optional.β¦