How To Join Multiple Strings into a Single String?

deepak singh
Posts: 686
Joined: Fri Sep 30, 2016 4:19 pm

How To Join Multiple Strings into a Single String?

Postby deepak singh » Sat Oct 01, 2016 4:54 pm

How To Join Multiple Strings into a Single String?

rameshkhd
Posts: 1279
Joined: Sun Aug 28, 2016 10:45 am

Re: How To Join Multiple Strings into a Single String?

Postby rameshkhd » Sat Oct 01, 2016 4:55 pm

If you multiple strings stored in an array, you can join them together into a single string with a given delimiter by using the implode() function. Here is a PHP script on how to use implode():
<?php
$date = array('01', '01', '2006');
$keys = array('php', 'string', 'function');
print("A formated date: ".implode("/",$date)."\n");
print("A keyword list: ".implode(", ",$keys)."\n");
?>
This script will print:
A formated date: 01/01/2006
A keyword list: php, string, function


Return to “PHP”

Who is online

Users browsing this forum: No registered users and 2 guests