codice:
<pre>
<?php
set_time_limit(14400);
$aree = array ("AA","AC","AB","AD","AE","AH","AJ","AK","AL","AM","AN","EQ","AP","AO","FA","AQ",
"ER","AR","AV","AW","AS","AT","AZ","BA","BB","BC","BG","BE","BD","BJ","BF","BH",
"BK","BN","BL","BM","EP","BV","BZ","BP","BR","BS","AF","BQ","BT","BW","AG","CA",
"BO","CC","CB","CD","ES","CZ","CG","CE","CF","ET","CJ","CL","CM","CK","CH","CN",
"CO","CP","DB","CV","CQ","CW","CS","CR","CT","DA","DE","DF","FB","EZ","EW","DG",
"DJ","DK","DM","DH","DN","DO","DC","EV","DD","DS","DT","DV","EF","EG","DZ","EH",
"EA","EJ","DR","DQ","DP","DW","ED","EB","EC","EE","EK","EL","EO","EM","DL","EN");
for( $i=0 ; $i<count($aree) ; $i++)
{
if( file_exists( "D:/FILE_BCE_$aree[$i]_2010.TXT" ) )
{
$con = mysql_connect( "localhost" , "root" , "");
$db = mysql_select_db( "test" , $con );
$file = fopen("D:/FILE_BCE_$aree[$i]_2010.TXT","r");
while(!feof($file))
{
$rec = fgetcsv( $file , 100000 , ";" );
$sql= "insert into bce values('','$aree[$i]',";
for( $ii=0 ; $ii<19 ; $ii++ )
{
$rec[$ii] = str_ireplace( "'" , "" , $rec[$ii] );
$rec[$ii] = str_ireplace( '"' , '' , $rec[$ii] );
$sql = $sql . "'" . $rec[$ii] . "',";
}
$sql = $sql . "'" . $rec[19] . "');";
if( !mysql_query($sql) )
die( mysql_error() );
}
fclose($file);
mysql_close( $con );
}
}
?>
</pre>