To convert array to string, use the concept of implode () in PHP. Let’s say the following is our array −
$sentence = array('My','Name','is','John');To convert the above array to string −
,implode(" ",$sentence)Example
<!DOCTYPE html>
<html>
<body>
<?php
$sentence = array('My','Name','is','John');
echo "The string is=",implode(" ",$sentence);
?>
</body>
</html>Output
The string is = My Name is John
Let us now see another PHP code wherein we will add separator as well −
Example
<!DOCTYPE html>
<html>
<body>
<?php
$sentence = array('One','Two','Three');
echo "The string is=",implode("*",$sentence);
?>
</body>
</html>Output
The string is = One*Two*Three