Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $filename = "test.ini";
- $handle = @fopen($filename, "r");
- $result = [];
- if ($handle) {
- while (($buffer = fgets($handle, 4096)) !== false) { //строка до 4КБ
- list($inikeys, $value) = explode('=', $buffer);
- $inikeys = explode('.', $inikeys);
- $current = &$result;
- foreach ($inikeys as $key => $inikey){
- if(!array_key_exists( $inikey, $current ) && $key + 1 < count($inikeys)){
- $current[$inikey] = [];
- }
- $current = &$current[$inikey];
- }
- $current = str_replace("\n", '', str_replace("\r", '', $value));
- unset($current);
- }
- fclose($handle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement