i am trying to get this to format the data properly.
I want it to format like this 'D',E','F','G','H'
But this is what i get: "D"E","F","G","H","I",J" "",
$colour = "D-E-F-G-H-I-J-"; // string to be formatted.
$colours = explode('-', $colour);
$num_items = count($colours);
$colour_is = '';
$i = 0;
foreach ($colours as $key => $value) {
if ($i == 0) {
// first
$colour_is .= ' "'. $value;
} else if ($i == $num_items - 1) {
// last
$colour_is .= $value. '" ';
}else{
$colour_is .= '"'. $value .'",';
}
$i++;
}
print_r($num_items .' - '. $colour_is);
Help on this would be nice. Thanks.