problem with parse_ini_file
<p>I'm using parse_ini_file() to read an ini file that has this line:</p>

<pre><code>[admin]
hide_fields[] = ctr_ad_headerImg
</code></pre>

<p>the problem is that it outputs it like,</p>

<pre><code>[admin]
hide_fields = Array
</code></pre>

<p>can someone help me out? how do I read "hide_fields[]" like a string?</p>

<p>Best Regards
Joricam</p>

<p>My code is:</p>

<pre><code>$ini_array = parse_ini_file($config_path, true);
//print_r($ini_array);
//echo $ini_array["default_colors"]["sitebg"];
$ini_array["default_colors"]["sitebg"]="#000000";
write_php_ini($ini_array,$config_path);
</code></pre>

<p>Functions that Im using:</p>

<pre><code>function write_php_ini($array, $file)
{
    $res = array();
    foreach($array as $key =&gt; $val)
    {
        if(is_array($val))
        {
            $res[] = "[$key]";
            foreach($val as $skey =&gt; $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : ''.$sval.'');
        }
        else $res[] = "$key = ".(is_numeric($val) ? $val : ''.$val.'');
    }
    safefilerewrite($file, implode("\r\n", $res));
}
//////
function safefilerewrite($fileName, $dataToSave)
{    if ($fp = fopen($fileName, 'w'))
    {
        $startTime = microtime();
        do
        {            $canWrite = flock($fp, LOCK_EX);
           // If lock not obtained sleep for 0 - 100 milliseconds, to avoid collision and CPU load
           if(!$canWrite) usleep(round(rand(0, 100)*1000));
        } while ((!$canWrite)and((microtime()-$startTime) &lt; 1000));

        //file was locked so now we can store information
        if ($canWrite)
        {            fwrite($fp, $dataToSave);
            flock($fp, LOCK_UN);
        }
        fclose($fp);
    }

}
</code></pre>
