Config_Container::toArray
Config_Container::toArray() – Return key/value pair array of container and its children
Synopsis
require_once 'Config/Container.php';
array Config_Container::toArray (
void
)
Описание
This method returns an array representation of the Config tree. The format is
<?php
$section[directive][index] = value
?>
If the container has attributes, it will use '@'
as key
for attributes and '#'
for values.
index is here because multiple directives and sections can have the same name,
the toArray() method takes care of that.
Return value
array
- an array representation of
the Config_Container tree
Замечание
This function can not be called statically.
Пример
Using toArray()()
<?php
$attributes = array('id' => 'db', 'language' => 'en');
$section =& new Config_Container('section', 'main', null, $attributes);
$section->createDirective('authentication', 'one', array('type' => 'mysql'));
$section->createDirective('authentication', 'two', array('type' => 'oracle'));
$section->createDirective('permission', 'group');
var_dump($section->toArray());
?>
Resulting array with attributes and directives with same name or not
array(1) {
["main"]=>
array(3) {
["@"]=>
array(2) {
["id"]=>
string(2) "db"
["language"]=>
string(2) "en"
}
["authentication"]=>
array(2) {
[0]=>
array(2) {
["#"]=>
string(3) "one"
["@"]=>
array(1) {
["type"]=>
string(5) "mysql"
}
}
[1]=>
array(2) {
["#"]=>
string(3) "two"
["@"]=>
array(1) {
["type"]=>
string(6) "oracle"
}
}
}
["permission"]=>
string(5) "group"
}
}