コード例 #1
0
ファイル: EIConfig.php プロジェクト: harturch/easyinterface
 static function xml2array($xmlObject, $out = array())
 {
     foreach ($xmlObject->attributes() as $attr => $val) {
         $out['@attr'][$attr] = (string) $val;
     }
     $has_childs = false;
     foreach ($xmlObject as $index => $node) {
         $has_childs = true;
         $out[$index][] = EIConfig::xml2array($node);
     }
     if (!$has_childs && ($val = (string) $xmlObject)) {
         $out['@value'] = $val;
     }
     foreach ($out as $key => $vals) {
         if (is_array($vals) && count($vals) === 1 && array_key_exists(0, $vals)) {
             $out[$key] = $vals[0];
         }
     }
     return $out;
 }