Quote Originally Posted by maki
That's the code i am using

Code:
if( !in_array( $_POST['cid'], $existing_courses)){ 
copy_course($FILE_LIB_XML, $FILE_ARCHIVE_XML, $FILE_USERS_XML, $cid );
And here is how i used your code to replace the above

Code:
$existing_courses = get_infos($FILE_ARCHIVE_XML, $cid); 
if(!$existing_courses) 
  echo 'there was no data in that xml file'; 
else{ 
copy_course($FILE_LIB_XML, $FILE_ARCHIVE_XML, $FILE_USERS_XML, $cid );}
I can not understant why the archive.xml is being updaded and still the php returns the warning which disapears when i refresh the page

Thanks
no, you're doing that wrong. you are supposed to be using is_array inside your function and not calling foreach() if the $cnt variable is NOT an array. your function should be structured like this (of course, the "blah"s are simply filler that you must replace real code with -- this just gives you the general idea):
PHP Code:
function get_infos($xml$id){ //<-- start function
  //blah blah
  
$cnt $child->childNodes;
  if(
is_array($cnt)){ //<-- this was added
    
foreach($cnt as $cn){
      
//blah blah blah
    
}
    return 
$mtd;
  }else 
//<-- this and the line below were also added
    
return false;
//<-- end function 
then, when you are calling get_infos(), you can use the code in my first post to see if the XML file had any information in it.
PHP Code:
$courses getinfos($archive_xml$id);
if(!
$courses)
  echo 
'no data was found in the xml file';
else
  
copy_course($lib_xml$archive_xml$users_xml$id);