PHP Implode() Function
0 3095
PHP implode() function is used to joining an array with the string like if you want to get the multiple values of array in a string then use the implode function.
<?php $getdata=array("I", "want", "to", "change", "the", "format", "of", "line."); $final_string=implode('-', $getdata); echo $final_string; ?>
Output:
I-want-to-change-the-format-of-line.
implode(separator,array)
Here:
1. separator: is used to put the string with what you want to join. Default string is an empty string (i.e. "")
2. array: is mandatory and used to join to a string.
You can use different types of strings to join
<?php $getdata=array("I", "want", "to", "change", "the", "format", "of", "line."); $final_string=implode(',', $getdata); echo $final_string; ?>
Output:
I,want,to,change,the,format,of,line.
Share:
Comments
Waiting for your comments