Search This Blog

array to string in php

<?php

$num1=array(1,2,3,4,5,6,7,8,9,10);
echo '<b>the array :</b>';
foreach($num1 as $num)
{
echo ' '.$num;
}


$string = join(',', $num1);
echo '<br><b>the string :</b>'.$string;

?>

output :

the array : 1 2 3 4 5 6 7 8 9 10

the string :1,2,3,4,5,6,7,8,9,10

Share Links

Related Posts Plugin for WordPress, Blogger...