What is tht implode() function in php ?
The implode() function basically utilized to join elements of an array with a string. So in other word we can say, it takes an array and returns a string.
syntax of implode() function
implode (separator, array_name)
implode(separator,array)
means there are two main important thing in implode() function
1-separator
2-array_name
You can take reference form below example of implode() function in php.
<?php
$address=array('Country Name', 'Province Name', 'City Name');
//here $address is a array_name
$resuldata=implode("-", $address);
//here $resuldata is a varible in which store array list
//now call implode() function with "-" separator
print ($resuldata);
echo '<br>';
$resuldata=implode(" ", $address);
//now call implode() function with " " separator
print ($resuldata);
?>
so output will come following:
1-when use "-" separator then output will come
Country Name-Province Name-City Name
2-when use " " separator then output will come
Country Name Province Name City Name
0 Comment(s)