Using a variable in an array index

hello kirupians

I’ve build an array such as

$list = [‘apple’ => ‘red’, ‘banana’ => ‘yellow’]

But I can’t seem to be able to call that in php, here’s what I’m doing now

$index = ‘apple’;
echo "Colour of $index is ".$list[$index];

Did I do something wrong ?