PHP function GLOB: get and modify the results -


i'm trying import many xml files not know name. use code:

foreach(glob('old/*.xml') $file) { $url=  basename($file) . ', '; $all_urls = array($url); foreach ($all_urls $url) {     $xml = simplexml_load_file($url); 

i have lot of files agency.xml, annunci_324.xml, annunci_321.xml, ecc...

i need files begin annunci , end .xml. need delete last value's comma , put in last foreach. how can it?

i think can check if name contains annunci strstr function (documentation here)

if(strstr($file, 'annunci') {     //we found file name interessed in. 

now can build directly array without caring commas

$all_urls = array(); foreach(glob('old/*.xml') $file)  {    if(strstr($file, 'annunci')    {        $all_urls[] = array(basename($file));    } } 

this way have all_urls array of files starting annunci , can loop in simple_load them all.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -