When creating file in csv using fputcsv then long integers show in scientific notation.
Example - 0133211000000140 is showing 1.33211E+14
fputcsv($file, array('Id','DESTINATION_ACCOUNT','SOURCE_ACCOUNT'));
if(!empty($data)){
foreach($data as $key => $row){
fputcsv($file,[$row['ID']
$row['DESTINATION_ACCOUNT'], -- scientific notation instead of long integer
$row['SOURCE_ACCOUNT'] -- scientific notation instead of long integer
]
);
}
}
That happens with floating points that have lots of digits:
https://www.php.net/manual/en/language.types.integer.php
echo gettype(1.33211E+14);outputs:double.If you do
printf('%d', '1.33211E+14');, orprintf('%.0f', '1.33211E+14');, orecho (int)1.33211E+14;, you'll get a decimal representation. That representation might be wrong.outputted:
If you're handling numbers larger than
PHP_MAX_INT, it may be better to have them represented as strings and use GMP for the operations.