String implode

String implode


Posted in : PHP Posted on : January 7, 2011 at 6:33 PM Comments : [ 0 ]

This section contains the detail about implode function of string in PHP.

String implode

The implode() function is opposite of explode(). It adds the different chunks into one joined chunks.

Example :

In the given below example, the array variable holds different strings and they joined together using implode() as given below :

<?php
$parts = array("God", "is", "always", "kind");

$withSpaces = implode(" ", $parts);
$withDashes = implode("-", $parts);
for($i = 0; $i < count($parts); $i++){
echo "Part-$i = $parts[$i] <br />";
}
echo "Glued with Spaces = $withSpaces <br />";
echo "Glued with Dashes = $withDashes";
?>

Output :

Part-0 = God
Part-1 = is
Part-2 = always
Part-3 = kind
Glued with Spaces = God is always kind
Glued with Dashes = God-is-always-kind

Download Source Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics