Exemple #1
0
 function _fromArray_getExtractSub($v)
 {
     // is it a string, a numerical array or an associative array?
     $sub = "_fromArray_extract";
     if (is_array($v)) {
         if (_MiniXML_NumKeyArray($v)) {
             // All numeric - assume it is a "straight" array
             $sub .= "ARRAY";
         } else {
             $sub .= "AssociativeARRAY";
         }
     } else {
         $sub .= "STRING";
     }
     return $sub;
 }
 function toStructure()
 {
     $retHash = array();
     $contents = "";
     $numAdded = 0;
     foreach ($this->xattributes as $attrname => $attrvalue) {
         $retHash[$attrname] = $attrvalue;
         $numAdded++;
     }
     for ($i = 0; $i < $this->xnumChildren; $i++) {
         if ($this->isElement($this->xchildren[$i])) {
             $name = $this->xchildren[$i]->name();
             $struct = $this->xchildren[$i]->toStructure();
             $existing = NULL;
             if (isset($retHash[$name])) {
                 $existing =& $retHash[$name];
             }
             if ($existing) {
                 if (_MiniXML_NumKeyArray($existing)) {
                     array_push($existing, $struct);
                 } else {
                     $newArray = array();
                     array_push($newArray, $existing);
                     array_push($newArray, $struct);
                     $retHash[$name] =& $newArray;
                 }
             } else {
                 $retHash[$name] = $struct;
             }
             $numAdded++;
         } else {
             $contents .= $this->xchildren[$i]->getValue();
         }
     }
     if ($numAdded) {
         if (!empty($contents)) {
             $retHash['-content'] = $contents;
         }
         return $retHash;
     } else {
         return $contents;
     }
 }