$in = fopen('original.csv', 'r'); $out = fopen('new.csv', 'w'); while( $row = fgetcsv( $in, 10000)){ if( $row[5] > 2 ){ fputcsv($out, $row); } } fclose($in); fclose($out); unlink('original.csv'); rename('new.csv', 'original.csv');
row[5] is the column number where quantity is. It starts from row[0].