What are some common pitfalls to avoid when working with JSON arrays in PHP?

One common pitfall when working with JSON arrays in PHP is not properly decoding the JSON string before trying to access its elements. To avoid this issue, always use `json_decode()` to convert the JSON string into a PHP array before working with it.

// Incorrect way: trying to access JSON elements without decoding
$jsonString = '{"name": "John", "age": 30}';
$decodedArray = $jsonString['name']; // This will not work

// Correct way: decoding JSON string before accessing elements
$jsonString = '{"name": "John", "age": 30}';
$decodedArray = json_decode($jsonString, true);
$name = $decodedArray['name']; // This will work correctly