In PHP, what are some best practices for handling and manipulating complex data structures like multi-dimensional arrays for efficient data retrieval and display?

When handling complex data structures like multi-dimensional arrays in PHP, it is important to use efficient methods for data retrieval and display to avoid performance issues. One best practice is to use nested loops to iterate through the array efficiently and access the desired elements. Additionally, utilizing built-in array functions like array_map, array_filter, and array_column can help simplify the manipulation of multi-dimensional arrays.

// Example of using nested loops to iterate through a multi-dimensional array
$data = [
    ['name' => 'John', 'age' => 25],
    ['name' => 'Jane', 'age' => 30],
    ['name' => 'Bob', 'age' => 35],
];

foreach ($data as $person) {
    foreach ($person as $key => $value) {
        echo "$key: $value" . PHP_EOL;
    }
}