Read INI file
Public functionReadini ($name){ if(file_exists(Sem_path. ' init/'.$name)){ $data=Parse_ini_file(Sem_path. ' init/'.$name,true); if($data){ return $data; } }Else { return false; }}
Write INI file
functionWrite_ini_file ($assoc _arr,$path,$has _sections=FALSE) { $content= ""; if($has _sections) { foreach($assoc _arr as $key=$elem) { $content.= "[".$key."] N; foreach($elem as $key 2=$elem 2) { if(Is_array($elem 2)) { for($i= 0;$i<Count($elem 2);$i++) { $content.=$key 2." [] = "".$elem 2[$i]."" N; } } Else if($elem 2=="")$content.=$key 2. "= n"; Else $content.=$key 2." = "".$elem 2."" N; } } } Else { foreach($assoc _arr as $key=$elem) { if(Is_array($elem)) { for($i= 0;$i<Count($elem);$i++) { $content.=$key 2." [] = "".$elem[$i]."" N; } } Else if($elem=="")$content.=$key 2. "= n"; Else $content.=$key 2." = "".$elem."" N; } } if(!$handle=fopen($path, ' W ')) { return false; } if(!fwrite($handle,$content)) { return false; } fclose($handle); return true; } Usage$sampleData=Array( ' First ' =Array( ' First-1 ' = 1, ' first-2 ' + 2, ' first-3 ' and 3, ' first-4 ' = 4, ' first-5 ' and ' 5, ), ' second ' =Array( ' Second-1 ' = 1, ' second-2 ' + 2, ' second-3 ' and 3, ' Seco Nd-4 ' = 4, ' second-5 ' + 5,)); Write_ini_file ($sampleData, './data.ini ',true);
PHP read/write INI file