What is the difference between traditional arrays and PHP's HashMap when it comes to indexing?

Traditional arrays in PHP use numerical indexes to access elements, while PHP's HashMap (associative arrays) use keys to access elements. The difference lies in how the elements are stored and accessed. Traditional arrays are indexed numerically starting from 0, while HashMaps allow you to define your own keys for each element.

// Traditional array
$traditionalArray = array("apple", "banana", "cherry");
echo $traditionalArray[1]; // Outputs: banana

// HashMap
$hashMap = array("fruit1" => "apple", "fruit2" => "banana", "fruit3" => "cherry");
echo $hashMap["fruit2"]; // Outputs: banana