I have an array $bobby with the following arrays inside. It is sorted by id.
1
id="1"
color="blue"
size="7"
height="10"
beebop="z"
2
id="2"
color="red"
size="64"
height="52"
beebop="y"
3
id="3"
color="pink"
size="72"
height="39"
beebop="not_x"
I am having trouble creating the php function that will create a simplified array ($bobby_simplified
) which only contains two values, id and color? So, the new array would look like this:
1
id="1"
color="blue"
2
id="2"
color="red"
3
id="3"
color="pink"
Also, in that function, can we sort by color ascending?
I tried the following but with no luck:
foreach ($bobby AS $bobby_simplified) {
$id = $bobby_simplified['id'];
$color = $bobby_simplified['color'];
}