Pull to refresh
0
0
Василий Соколов @megawilddaddy

User

Send message
Без проверок и прочего я бы написал так

function read_conf($fileName)
{
$result = array();
$fp = fopen($fileName, 'r');

while ($line = fgets($fp)) {
list($key, $value) = explode('=', $line);
$keyParts = explode('.', $key);
setValueFromKeyParts($result, $keyParts, $value);
}

return $result;
}

function setValueFromKeyParts(&$result, &$parts, $value)
{
$part = array_shift($parts);

if (count($parts) == 0) {
$result[$part] = $value;
} else {
if (!isset($result[$part])) {
$result[$part] = array();
}
setValueFromKeyParts($result[$part], $parts, $value);
}
}

Information

Rating
Does not participate
Location
Санкт-Петербург и область, Россия
Date of birth
Registered
Activity