PHP Example | Convert Array to String

This php example code will introduce how to convert an array to string.

$arra = array (? This " , " Is " , " An " , " ARRAY" , " ! " );  
  
echo " <h4> "." Default array " . " </h2> ";  
print_r ($arra);  
  
echo " <h4> " . " Array to string " . " </h2> ";  
echo implode(" ",$arra)."<br>"; // default separator  
echo implode("_",$arra)."<br>";  
echo implode("-",$arra)."<br>";   
echo implode("/",$arra);  
  
echo " <h4> " . " Data type: - " . " </h2> ";  
echo gettype ($arra);  

Run this php code, we will get:

Default array
Array ( [0] => This [1] => Is [2] => An [3] => ARRAY [4] => ! ) 
Array to string
This Is An ARRAY ! 
This _ Is _ An _ ARRAY_ ! 
This - Is - An - ARRAY- ! 
This / Is / An / ARRAY/ ! 
Data type: -
Array