When accessing elements in an array in PHP, what is the difference between using arrow notation and square brackets, and what are the implications for code execution?

When accessing elements in an array in PHP, using square brackets is the standard way to access elements by their index. On the other hand, arrow notation is used to access elements in an associative array by their key. Using the wrong notation can lead to errors or unexpected behavior in your code.

// Using square brackets to access elements in a regular array
$regularArray = [1, 2, 3];
echo $regularArray[0]; // Output: 1

// Using arrow notation to access elements in an associative array
$assocArray = ['key' => 'value'];
echo $assocArray['key']; // Output: value