Ok I am on the last part YAY!!! I just can't figure this last one out. if I put in the array the actual body name it work however if I put in a variable it doesn't here is the excerpt and the full php When I use this code it doesn't bring over the XXXXbody.xml [code]$ourFileName2 = $ourFileName; Function chmod_xml() { chmod('1610body.xml', 0777); // octal; correct value of mode } chmod_xml(); Function create_xml() { $files = array('header.xml',$ourFileName2,'footer.xml'); foreach($files as $file) { $contents[] = file_get_contents($file); } $fp = fopen('new_file.xml','w+'); fwrite($fp,join("\n",$contents)); fclose($fp); } create_xml(); [/code] However if I manual type it in it works!!! any help would be appreciated [code]<?php /******START CODE EXTRACT******/ if(!function_exists("file_get_contents")) { function file_get_contents($f = null) { if(is_null($f)) return null; return implode("", file($f)); } } /*******END CODE EXTRACT*******/ $ourFileName = $campaign."body.xml"; if (file_exists($ourFileName)) { $fh = fopen($ourFileName, 'a'); } else { $fh = fopen($ourFileName, 'w') or die("can't open file"); } $record = "<record>"; $campaignid = "<campaignid>"; $experienceid = "<experience>"; $noteid = "<note>"; $nameid = "<name>"; $record2 = "</record>"; $campaignid2 = "</campaignid>"; $experienceid2 = "</experience>"; $noteid2 = "</note>"; $nameid2 = "</name>"; fwrite($fh, $record); fwrite($fh, "\n"); fwrite($fh, "\n"); fwrite($fh, $campaignid); fwrite($fh, $campaign); fwrite($fh, $campaignid2); fwrite($fh, "\n"); fwrite($fh, "\n"); fwrite($fh, $experienceid); fwrite($fh, $experience); fwrite($fh, $experienceid2); fwrite($fh, "\n"); fwrite($fh, "\n"); fwrite($fh, $noteid); fwrite($fh, $note); fwrite($fh, $noteid2); fwrite($fh, "\n"); fwrite($fh, "\n"); fwrite($fh, $nameid); fwrite($fh, $name); fwrite($fh, $nameid2); fwrite($fh, "\n"); fwrite($fh, "\n"); fwrite($fh, $record2); fclose($fh); $ourFileName2 = $ourFileName; Function chmod_xml() { chmod('1610body.xml', 0777); // octal; correct value of mode } chmod_xml(); Function create_xml() { $files = array('header.xml','1610body.xml','footer.xml'); foreach($files as $file) { $contents[] = file_get_contents($file); } $fp = fopen('new_file.xml','w+'); fwrite($fp,join("\n",$contents)); fclose($fp); } create_xml(); ?>[/code]