previousConfig_Container::setType (Previous) (Next) Config_Container::toStringnext

View this page in Last updated: Sun, 18 Oct 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Config_Container::toArray

Config_Container::toArray() – Retourne un tableau avec un couple clé/valeur du conteneur et ses enfants

Synopsis

require_once 'Config/Container.php';

array Config_Container::toArray ( ( void )

Description

Cette méthode retourne un tableau représentatif de l'arbre Config. Le format est :

<?php
$section
[directive][index] = value
?>
Si le conteneur a des attributs, il utilisera '@' comme clé pour les attributs et '#' pour les valeurs. index est là parce que plusieures directives et sections peuvent avoir le même nom, la méthode toArray() en tient compte.

Return value

array - un tableau représentatif de l'arbre Config_Container

Note

This function can not be called statically.

Example

Exemple avec toArray()()

<?php
$attributs 
= array('id' => 'db''language' => 'en');
$section =& new Config_Container('section''main'null$attributs);
$section->createDirective('authentication''one', array('type' => 'mysql'));
$section->createDirective('authentication''two', array('type' => 'oracle'));
$section->createDirective('permission''group');
var_dump($section->toArray());
?>

Tableau de résultat avec des attibuts et des directives avec des noms identiques ou non


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"
    }
}
previousConfig_Container::setType (Previous) (Next) Config_Container::toStringnext

Download Documentation Last updated: Sun, 18 Oct 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.