Beispiel #1
0
 public static function _xml_depth($vals, &$i)
 {
     $children = array();
     if (isset($vals[$i]['value'])) {
         array_push($children, $vals[$i]['value']);
     }
     while (++$i < count($vals)) {
         switch ($vals[$i]['type']) {
             case 'open':
                 if (isset($vals[$i]['tag'])) {
                     $tagname = $vals[$i]['tag'];
                 } else {
                     $tagname = '';
                 }
                 if (isset($children[$tagname])) {
                     $size = sizeof($children[$tagname]);
                 } else {
                     $size = 0;
                 }
                 if (isset($vals[$i]['attributes'])) {
                     $children[$tagname][$size]['@'] = $vals[$i]["attributes"];
                 }
                 $children[$tagname][$size]['#'] = Jabber::_xml_depth($vals, $i);
                 break;
             case 'cdata':
                 array_push($children, $vals[$i]['value']);
                 break;
             case 'complete':
                 $tagname = $vals[$i]['tag'];
                 if (isset($children[$tagname])) {
                     $size = sizeof($children[$tagname]);
                 } else {
                     $size = 0;
                 }
                 if (isset($vals[$i]['value'])) {
                     $children[$tagname][$size]["#"] = $vals[$i]['value'];
                 } else {
                     $children[$tagname][$size]["#"] = array();
                 }
                 if (isset($vals[$i]['attributes'])) {
                     $children[$tagname][$size]['@'] = $vals[$i]['attributes'];
                 }
                 break;
             case 'close':
                 return $children;
                 break;
         }
     }
     return $children;
 }