How to Use Implode() function in PHP?

Implode() function

Implode() function in PHP is used to convert an array to string.

syntax:

implode(separator,array)

Example:

<?php
$arr = array('php','html','jquery','css','javascript');
$res = implode( " " , $arr );
print_r( $res );
?>

output:

php html jquery css javascript

In the above example we can see that we have created array( “php”,”html”,”jquery”,”css”,”javascript” ) array. And to convert this array into string we have used implode() function.In the implode function, two parameters have to be set, first that is the separator parameter, if after converting the array into a string, the output of the sting will be shown with which separator, it defines if we have ” + ” and ” in the separator. “And if others use any B operator, then it is shown in the string. If you set a space in the separator, then it will show with the word space of the string.