I have a PHP array and want to convert it to a string.
I know I can use join or implode, but in my case array has only one item. Why do I
join
implode
Convert array to a string in PHP:
Use the PHP join function like this:
$my_array = array(4,1,8); print_r($my_array); Array ( [0] => 4 [1] => 1 [2] => 8 ) $result_string = join(',' , $my_array); echo $result_string;
Which delimits the items in the array by comma into a string:
4,1,8