Join (converting an array to variable or string) in php example

Join is used to convert an array variable to string variable.

Program: join.php

<?php
$array5=array('mother','father','brother','sister');
echo "printing as array\n";
print_r($array5);
$string_variable=join(',',$array5); 
//array5 contents are separated by comma and stored in string_variable.
echo "printing as a single variable separated by comma using join()\n";
echo "$string_variable";
?>

 

 Output:

join

 

 

 

Thanks for reading this post……….!!!

Leave a Reply