コード例 #1
0
ファイル: common.php プロジェクト: ashanrupasinghe/slbcv2
 /**
  * Convert xml to array
  *
  * @param JSimpleXML $xml   Object XML
  *
  * @return array
  */
 public static function xmltoarray($xml)
 {
     if (!$xml) {
         return null;
     }
     $arr = array();
     $arr['name'] = $xml->_name;
     $arr['data'] = $xml->_data;
     // Remove blank space for module position
     if ($arr['name'] == 'block') {
         $arr['data'] = preg_replace('/\\s/', '', $arr['data']);
     }
     $arr['attributes'] = $xml->attributes();
     $arr['children'] = array();
     if (count($xml->children())) {
         foreach ($xml->children() as $child) {
             $arr['children'][] = T3Common::xmltoarray($child);
             // Assign parent for block
             if ($arr['name'] == 'blocks') {
                 $arr['children'][count($arr['children']) - 1]['attributes']['parent'] = $arr['attributes']['name'];
             }
         }
     }
     return $arr;
 }