What are the potential pitfalls of using arrays in PHP to handle data processing?

One potential pitfall of using arrays in PHP for data processing is the risk of running into memory limitations when dealing with large amounts of data. To avoid this issue, consider using generators instead of arrays to process data in a more memory-efficient manner.

// Using generators instead of arrays for memory-efficient data processing
function processData($data) {
    foreach ($data as $item) {
        yield $item;
    }
}

// Example usage
$data = range(1, 1000000);
foreach (processData($data) as $item) {
    // Process each item
}