I am using php to sort records from a csv file based on a key value. I have 1584 records in a csv file. After reading each record I am sorting all the records in descending order based upon a key value. When I am writing the sorted array only 792(half of 1584) records are getting inserted. Is there any limit for entering maximum number of records that we can append to a csv file through php code. My code is as follows:
<?php
$handle=fopen("entiredata1.csv","r");
$i=0;
while($record=fgetcsv($handle,250))
{
$list[$i]=$record;
$i=$i+1;
}
fclose($handle);
$j=$i;
echo "j=$j <br>";
echo "i=$i <br>";
for($i=0;$i<$j;$i++)
{
for($k=0;$k<$i;$k++)
{
if($list[$i][12] > $list[$k][12])
{
$temp=$list[$i];
$list[$i]=$list[$k];
$list[$k]=$temp;
}
}
}
$whandle=fopen("sorted.csv","a");
for($i=0;$i<$j;$i++)
{
fputcsv($whandle,$list[$i]);
$i=$i+1;
}
fclose($whandle);
?>