} public function set_contact($arr) { $this->arr_contact = $arr; } public function get_resume_attributes() { $arr_attributes; $arr_attributes = get_object_vars($this); return $arr_attributes; } } $obj_resume = new Resume(); $obj_resume->set_name($_GET['name']); //print_r($contact); $obj_resume->set_contact($contact); $obj_resume->set_education($_GET['education']); //print_r($obj_resume); //$out=xml_to_array($obj_resume); //echo $out; $arr_resume = $obj_resume->get_resume_attributes(); //print_r($arr_resume); //loop_array($arr_resume); //$xml_out=xml_to_array($arr_resume); $xml_out = capsulate_xml($arr_resume, "resume"); echo $xml_out; function loop_array($array) { foreach ($array as $key => $value) { # code... echo $key;