I have a simple array $arr
which contains 6 numbers.
$arr=[10,24,33,47,58,65];
I want to assign each number to a variable prefixed $color
so $color1
, $color2
etc up to $color6
This then gives $color1
a value of 10, $color2
a value of 24 etc
Then I want to print each of them out e.g. echo $color1;
echo $color2;
etc
This is what I'm trying but it doesn't work, is there a better way?
$i=1;
foreach($arr as $row)
{
$color.$i = implode(",",$row);
$i++;
}