Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- function readCSV($csvFile){
- $file_handle = fopen($csvFile, 'r');
- while (!feof($file_handle) ) {
- $line_of_text[] = fgetcsv($file_handle, 20000);
- }
- fclose($file_handle);
- return $line_of_text;
- }
- // Set path to CSV file
- $csvFile = 'test.csv';
- $csv = readCSV($csvFile);
- echo '<pre>';
- print_r($csv);
- echo '</pre>';
- //sortinng by pos ke 1
- $pos=1; //dimulai dari 0 tp saya milih 1
- $data=array();
- foreach($csv as $id=>$arr){
- $id2=sprintf("%09s",$id);
- $data[ $arr[$pos].$id2 ] = $arr;
- }
- ksort($data);
- echo '<pre>'.print_r($data,1).'</pre>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement