PHP Implode() Function || PHP Functions
×


PHP Implode() Function

0 1057

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:


Leave a Reply


Comments
    Waiting for your comments