PHP Large Data Handle (10million data)-WebJourney

PHP Large Data Handle (10million data)-WebJourney

Hello PHP lovers you may have a very good news i.e we are going to handle large data for example 10 million data in PHP. To handle large data in php we must use create a generator function using the yield keyword. The yield keyword is used to create a generator function. PHP generator can manage big data like 10m, 15m and much more. I will show you the best way to handle php large data. Using few lines of simple code we will manage the big amount of data in PHP.

 

Look at the example code, here we will test for 100k, 200k, half million and then 1 million. You can test according to your needs.

Note: You may set memory limit.

<?php 

ini_set('max_execution_time', 0); // Set no time limit
ini_set('memory_limit', '1024M'); // Set memory limit to 1024 megabytes
function countUpTo($limit)
{
    for ($i = 1; $i <= $limit; $i++) {
        yield $i;
    }
}

//$generator = countUpTo(200000);
//$generator = countUpTo(200000);
//$generator = countUpTo(500000);
$generator = countUpTo(1000000);
foreach ($generator as $number) {
    echo $number . ' <br>';
}

 

This way we can manage large data in php. Thanks to read this article

 

 

 

If you like what you are reading, please think about buying us a coffee as a token of appreciation.

Buy Me A Coffee

We appreciate your support and are committed to providing you useful and informative content.

We are thankful for your ongoing support 

Tags

  • Share This: