$val) { if($get_attributes == 1) $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr' /** :TODO: should we change the key name to '_attr'? Someone may use the tagname 'attr'. Same goes for 'value' too */ } } } elseif(isset($value)) { $result = $value; } //See tag status and do the needed. if($type == "open") {//The starting of the tag " $parent[$level-1] = &$current; if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag $current[$tag] = $result; $current = &$current[$tag]; } else { //There was another element with the same tag name if(isset($current[$tag][0])) { array_push($current[$tag], $result); } else { $current[$tag] = array($current[$tag],$result); } $last = count($current[$tag]) - 1; $current = &$current[$tag][$last]; } } elseif($type == "complete") { //Tags that ends in 1 line " //See if the key is already taken. if(!isset($current[$tag])) { //New Key $current[$tag] = $result; } else { //If taken, put all things inside a list(array) if((is_array($current[$tag]) and $get_attributes == 0)//If it is already an array… or (isset($current[$tag][0]) and is_array($current[$tag][0]) and $get_attributes == 1)) { array_push($current[$tag],$result); // …push the new element into that array. } else { //If it is not an array… $current[$tag] = array($current[$tag],$result); //…Make it an array using using the existing value and the new value } } } elseif($type == 'close') { //End of tag " $current = &$parent[$level-1]; } } return($xml_array); } class parsexml{ var $res; function make_massiv($contents) { $contents = '' . $contents . ''; $contents = xml2array($contents); $s = $contents['data']; foreach ($s as $key => $value) { $massiv[$key] = @$value['value']; } $this->res=$massiv; } } $parce = new parsexml; ?>