I would like to introduce about usege of a Generator in PHP. For that purpose i've taken this as an example to learn.
Suppose you've a 4GB of CSV file and you need to iterate as a stream resource. Generally our VPS allows 1GB to 2GB of memory. Hence there's no way to get out but have to take help of PHP generator.
Please check the example below as a reference.
function getCsvFileRow($bigDataFile) {
$handler = fopen($bigDataFile, 'r');
if($handler === false){ throw new Exception(); }
while(feof($handler) === false){ yield fgetcsv($handler); }
fclose($handler);
}
foreach(getCsvFileRow('pathToCsvFile/dataFile.csv') as $dataRow) {
print_r($dataRow);
}
* Further details please refer Standard PHP Library (SPL) iterators.
Looking for a TYPO3 or Drupal or mean.io or React expert? Reach me at nirmalya.mondal@gmail.com
Tuesday, February 9, 2016
Monday, February 8, 2016
TYPO3 - typoscript based AJAX example for version 7.6.0
Need to write some text ... will be updated very soon ...
Here i've make one working example available for you and its here https://github.com/nirmalyamondal/Typo3-Extensions/tree/master/typo3_ajax
Here i've make one working example available for you and its here https://github.com/nirmalyamondal/Typo3-Extensions/tree/master/typo3_ajax
Subscribe to:
Posts (Atom)