simplexml_load_file timeout

function simplexml_load_file_from_url($url,$timeout=60){
	$opts=array('http'=>array('timeout'=>(int)$timeout));
	$context=stream_context_create($opts);
	$data=file_get_contents($url,false,$context);
	if(!$data){
		return false;
	}
	return simplexml_load_string($data);
}

использовать вместо simplexml_load_file

php save create dir

Для автоматического создания папок при использовании file_put_contents

function save_to_dir($to,$content){
	$path=pathinfo($to);
	if(!file_exists($path['dirname'])){
		mkdir($path['dirname'],0777,true);
	}
	return file_put_contents($to,$content);
}