CodesJava

Easy learning with example program codes

PHP program to join the array elements into a string

PHP program to join the array elements into a string:

The below program is to combine the array elements into a string with given delimiter using PHP join() function. The PHP echo statement is used to output the result on the screen. An array is a single variable which can store multiple values at a time. The PHP join() function is used to get a string by joining the elements of an array.
Example

<!DOCTYPE html>
<html>
<body>
 
<?php
$arr = array("Have", "Courage.", "Live", "Free.");
echo join(" ",$arr);
?>
 
</body>
</html>

Output

Have Courage. Live Free.
Please follow and like us:
error
Posted in PHP   








Copyright © 2019 CodesJava DMCA.com Protection Status