What are some common pitfalls when working with arrays in PHP, especially when accessing files like in this scenario?

One common pitfall when working with arrays in PHP, especially when accessing files, is not checking if the file exists before trying to access it. This can lead to errors or unexpected behavior if the file is not found. To solve this, you can use the `file_exists()` function to check if the file exists before attempting to access it.

$file_path = 'example.txt';

if (file_exists($file_path)) {
    $file_contents = file_get_contents($file_path);
    // Do something with the file contents
} else {
    echo 'File does not exist.';
}