Join/concatenate multiple strings into a single string in PHP using implode

An array of multiple strings can be joined together into a single string with a given delimiter by using the php implode() function.

Example code:

<?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");
?>

Output:

A formated date: 01/01/2006
A keyword list: php, string, function

Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

 

 
eXTReMe Tracker