Why do i get 'allowed memory size exhausted in php'?


$data = [];
for($i = 0; $i < 10000000; $i++) {
    $data[] = $i;

Filling up an array or data structure beyond the memory limit set for the script.


You can increase the memory limit, but it's often more beneficial to review the script to optimize memory usage.

// Optimize data handling or processing
// Avoid large data structures when not necessary

Beginner's Guide to PHP