I would like to combine the values which contain the prefix lt_ in $url with the values in $color and create a new array $new. Both arrays $url and $color store values for the next 36 hours:
print_r($url);
outputs
Array(
[0] => "http://example.com/color/green.png",
[1] => "http://example.com/color/lt_green.png",
[2] => "http://example.com/color/lt_blue.png",
[3] => "http://example.com/color/blue.png",
[4] => "http://example.com/color/blue.png",
[5] => "http://example.com/color/yellow.png",
..
[35] => "http://example.com/color/lt_blue.png",
);
and
print_r($color);
outputs
Array(
[0] => "Green",
[1] => "Green",
[2] => "Blue",
[3] => "Blue",
[4] => "Blue",
[5] => "Yellow",
...
[35] => "Blue",
);
I have managed to find the string part lt_ in $url and get the keys in $new but how can I add "Light" (or lt_) to the corresponding values in $color to populate $new?
$new = array(
[0] => "Green",
[1] => "Light Green",
[2] => "Light Blue",
[3] => "Blue",
[4] => "Blue",
[5] => "Yellow",
...
[35] => "Light Blue",
);
I have managed to create an array with only the keys which values contain lt_:
$lt = 'lt_';
foreach($url as $key1=>$value1)
{
foreach($color as $key2=>$value2)
{
if (strpos($value1,$lt) !== false)
{
$new[$key1] = array();
}
}
}