pyyyh... php.net er svært at overskue. Man kan jo ligefrem finde funktioner der...
<?php
function parse_ini_str($Str,$ProcessSections = TRUE) {
$Section = NULL;
$Data = array();
if ($Temp = strtok($Str,"\\r\\n")) {
do {
switch ($Temp{0}) {
case ';':
case '#':
break;
case '[':
if (!$ProcessSections) {
break;
}
$Pos = strpos($Temp,'[');
$Section = substr($Temp,$Pos+1,strpos($Temp,']',$Pos)-1);
$Data[$Section] = array();
break;
default:
$Pos = strpos($Temp,'=');
if ($Pos === FALSE) {
break;
}
$Value = array();
$Value["NAME"] = trim(substr($Temp,0,$Pos));
$Value["VALUE"] = trim(substr($Temp,$Pos+1),' "');
if ($ProcessSections) {
$Data[$Section][] = $Value;
}
else {
$Data[] = $Value;
}
break;
}
} while ($Temp = strtok("\\r\\n"));
}
return $Data;
}
?>
Example:
[Files]
File=File1
File=File2
would return:
array (
'Files' => array (
0 => array (
'NAME' => 'File',
'VALUE' => File1',
),
1 => array (
'NAME' => 'File',
'VALUE' => 'File2',
),
),
)