When referring to an element inside a PHP string like an array, using square brackets [ ] you can use a number like [2] to select a specific character from the string. However, when using a string index like ["example"], it always returns the same result as [0].
<?php
$str="Hello world.";
echo $str; // Echos "Hello world." as expected.
echo $str[2]; // Echos "l" as expected.
echo $str["example"]; // Echos "H", not expected.
$arr=array();
$arr["key"]="Test."
echo $arr["key"]; // Echos "Test." as expected.
echo $arr["invalid"]; // Gives an "undefined index" error as expected.
echo $arr["key"];
Why does it return the same result as [0]?