I have seen that this question already exist inside stackoverflow but there isn't an answer for my problem.
I have directory with many files downloaded from another server, I don't know how much files and how much is the dimension can be 1GB I think or 100Mb depends of the external server.
Now I have done in this way:
ini_set("memory_limit","10000M");
$directory = "xml_uploads/hotel/";
$xml_files = glob($directory . "*.xml");
foreach($xml_files as $file)
{
$content = file_get_contents($file, true);
$xml = new DOMDocument();
$xml->loadXML($content);
if($xml){
//parse xml and save inside database
}
}
I don't know if is the better way to insert inside memory_limit a large number like that because I don't know the rela size adn if is too bigger I don't want to stop my server. Exist another way to parse all the xml files inside a directory?
Thanks