php parse_ini_file oop & deep
Me gustaría hacer uso de algo como [parse_ini_file] [1].
Digamos, por ejemplo, que tengo un archivo boot.ini que cargaré para un procedimiento adicional:
;database connection settings
[database]
type = mysql;
host = localhost;
username = root;
password = "";
dbName = wit;
Sin embargo, me gustaría tenerlo de una manera diferente ya que la matriz php sería:
$ini['database']['whatever']
Así que, en primer lugar, me gustaría tener mi boot.ini como esta estructura:
;database settings (comment same style)
db.host1.type = mysql;
db.host1.host = localhost;
db.host1.username = root;
db.host1.password = "";
db.host1.dbName = wit;
db.host2.type = mysql;
db.host2.host = otherHost;
db.host2.username = root;
db.host2.password = "";
db.host2.dbName = wit;
Entonces, cuando ahora accedo al archivo, me gustaría acceder de esta manera:
$ini['db']['host1']['whatever']
Y además de eso, me gustaría hacerlo a través de OOP, así que digamos: $ ini-> db-> host1-> lo que sea
or `$ini->db->host1`
devolverá una matriz con todos los atributos como tipo, host, nombre de usuario, contraseña y dbName;
Agradezco cualquier tipo de ayuda. Muchas gracias por adelantado
[1]: http://uk2.php.net/manual/en/function.parse-ini-file.php