/** * Convert xml to array * * @param JSimpleXML $xml Object XML * * @return array */ 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; }