Advertisement
jamboljack

Array BIN

Apr 4th, 2019
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. public function index()
  2.     {
  3.         $src           = FCPATH . '/tap';
  4.         $dir           = opendir($src);
  5.         $results_array = array();
  6.         if (!$dir) {
  7.             log_message('ERROR', 'Direktori / File tidak Ada.');
  8.         } else {
  9.             while (($file = readdir($dir)) !== false) {
  10.                 $results_array[] = strtolower($file);
  11.                 $fileAsli        = FCPATH . 'tap/' . $file;
  12.                 $x               = explode('.', $file);
  13.                 $ekstensi        = strtolower(end($x));
  14.                 if ($ekstensi == 'bin') {
  15.                     // Proses Baca File bin
  16.                     $nama_file = pathinfo($file, PATHINFO_FILENAME) . '.bin';
  17.                     $fileOpen  = fopen($fileAsli, "r");
  18.                     while (!feof($fileOpen)) {
  19.                         $result  = fgets($fileOpen);
  20.                         $pemisah = ':';
  21.                         $pos     = strpos($result, $pemisah);
  22.                         if ($pos != false) {
  23.                             $hasil                                                   = explode(":", strtolower(trim($result)));
  24.                             $data[$nama_file][str_replace(" ", "", trim($hasil[0]))] = str_replace(",", "", trim($hasil[1]));
  25.                             // echo '<pre>';
  26.                             // print_r($data);
  27.                             // echo '</pre>';
  28.                         }
  29.                     }
  30.                     // Insert ke Table
  31.                     // foreach ($data as $namafile => $datanya) {
  32.                     //     $npwpd = $datanya['npwpd'];
  33.                     //     echo $npwpd;
  34.                     // }
  35.  
  36.                     fclose($fileOpen);
  37.                     // unlink($fileAsli);
  38.                 }
  39.             }
  40.  
  41.             closedir($dir);
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement