How to comma separate the values of an array for display How to comma separate the values of an array for display php php

How to comma separate the values of an array for display


You can simply use PHP's implode function for this purpose as follows:

$string = implode(',', array(1,2,3,4,5));


You can make use of list() function if you know there are only 3 values.

$array = array('Life', 'living', 'Health');list($life, $living, $health) = $array;echo $life;echo $living;echo $health;

Note - you can make use of implode function as well.