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... |