Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. /* duct_tape anyone ?*/
  2.             function parse_ini_file_fix($file) {
  3.                
  4.                 $fh = fopen($file, 'r');
  5.                
  6.                 $returnArray = array();
  7.                 while(false !== ($line = fgets($fh))) {
  8.                    
  9.                     if(preg_match("/[^;]+=.+/", $line)) {
  10.                         if(!preg_match('/\[.*\]/', $line)) {
  11.                             $exploded = explode('=', $line);
  12.                             $key = trim($exploded[0]);
  13.                             $value = trim(trim($exploded[1], '"'));    
  14.                             $returnArray[$key] = $value;                   
  15.                         } else {
  16.                             preg_match('/(.*)\[(.*)\] = (.*)/', $line, $matches);
  17.                             if(!empty($matches)) {
  18.                                 $returnArray[$matches[1]][$matches[2]] = $matches[3];
  19.                             }                                          
  20.                         }          
  21.                     }
  22.                    
  23.                 }
  24.                
  25.                 return $returnArray;
  26.                
  27.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement