lib/Util.php
public static function write($array, $filename, $header = '', $chmod = null)
    {
        $result = '';
        foreach ($array as $k => $v) {
            if (is_array($v)) {
                $result .= '['.$k."]\n";
                foreach ($v as $k2 => $v2) {
                    $result .= self::_iniValue($k2, $v2);
                }
            } else {
                // we put simple values at the beginning of the file.
                $result = self::_iniValue($k, $v).$result;
            }
        }

        if ($f = @fopen($filename, 'wb')) {
            fwrite($f, $header.$result);
            fclose($f);
            if ($chmod) {
                chmod($filename, $chmod);
            }
        } else {
            throw new IniException('Error while writing ini file '.$filename, 24);
        }
    }
public static function write($array, $filename, $header = '', $chmod = null)
    {
        $result = '';
        foreach ($array as $k => $v) {
            if (is_array($v)) {
                $result .= '['.$k."]\n";
                foreach ($v as $k2 => $v2) {
                    $result .= self::_iniValue($k2, $v2);
                }
            } else {
                // we put simple values at the beginning of the file.
                $result = self::_iniValue($k, $v).$result;
            }
        }

        if ($f = @fopen($filename, 'wb')) {
            fwrite($f, $header.$result);
            fclose($f);
            if ($chmod) {
                chmod($filename, $chmod);
            }
        } else {
            throw new IniException('Error while writing ini file '.$filename, 24);
        }
    }
write some data in an ini file
the data array should follow the same structure returned by
the read method (or parse_ini_file).

@param array  $array    the content of an ini file
@param string $filename the path and the name of the file use to store the content
@param string $header   some content to insert at the begining of the file
@param int    $chmod