If I have an array in php that contains a simple list e.g:
$colors = $array();
$colors = 'black', 'white', 'blue', 'red';
Is there a function or a way to loop through the array to make a variable equal a STRING of the results?
For example:
$theseColors = 'black, white, blue, red';
Cheers!
$theseColors = implode(', ',$colors);
$theseColors = implode(', ', $colors);
$colors = $array(); $colors = 'black', 'white', 'blue', 'red';
won't work. it's an error here. this is correct:
$colors = array(); $colors = array('black', 'white', 'blue', 'red');
and then
$theseColours = implode(", ", $colors);
foreach ($color as $colors) {
$theseColours = $theseColours . $color;
}