View Single Post
  #62  
Old 08-21-2007, 03:34 AM
Sabari Sabari is offline
D-Web Genius
 
Join Date: Jul 2007
Posts: 943
Sabari is on a distinguished road
Default Re: Using Arrays in PHP

Implode()

So exploding breaks the data apart, imploding brings the data together. The implode command will take the data from an array and assemble it into a single string.

We will use the newly created array from above and implode it into a new string.
<?php
$new_pantry = implode(" ",$pantry_food);
?>


Imploding uses a separator element as well. In this case, it adds the separator between each of the array elements when it creates the new string. The above example is using a space this time.

The new string :
<?php
echo "$new_pantry";
?>


Has the value of :

tomatoes oranges bananas potatoes bread apples
__________________
Thanks & Regards
Sabari...
Reply With Quote