Sono felice che tu abbia risolto, in ogni caso ho testato e migliorato lo script che ti avevo dato: ora funziona benissimo: dacci un'occhiata se ne hai voglia.

Codice PHP:
<html>
<head>
</head>
<body>
<div style="font-family:courier;">
<?php
$OK
=0;
$NO=0;
if (
$handle opendir('Catalogo')) {
while (
false !== ($file1 readdir($handle))) {

if (
$file1 != "." && $file1 != "..") {
$file file ("Catalogo/".$file1);
echo
'<h1>File '.$file1.' aperto correttamente: INIZIO PARSING:</h1>';

$species = array();

$family="";
$genus="";
echo
'<table border="1">';
echo
'<tr><td>identificatore</td><td>valore</td><td>family attuale</td><td>genus attuale</td></tr>';
foreach(
$file as $row//scorro l'array
{
echo
'<tr>';
$dati=explode(": ",$row);//divido in ogni riga l'identificatore(es genus) dal valore
$ident=$dati[0];//identificatore
if(count($dati)==2)
echo 
'<td>'.$ident.'</td>';
$value=$dati[1];//valore
if(count($dati)==2)
echo 
'<td>'.$value.'</td>';
if(
$ident=="family")//se il valore è identificato da family
$family=$value;//la famiglia presa in considerazione diventa quella identificata
if($ident=="genus")//se il valore è identificato da genus
$genus=$value;//il genere preso in considerazione diventa quello identificato
if($ident=="species")//se il valore è identificato da species
$species[$family][$genus][]=$value;//inserisco il valore in un array multidimensionale, identificandolo con family e genus
if(count($dati)==2)
echo
'<td>'.$family.'</td><td>'.$genus.'</td>';
echo
'</tr>';
}
echo 
'</table>';
echo 
'<h1>Parsing completato con successo!</h1><h1>Inizio inserimento dei dati nel database</h1>';
$fkeys=array_keys($species);
echo
'<h1>INIZIO ISPEZIONE ARRAY species:</h1>';
echo
'-famiglie totali: '.count($fkeys).'
'
;
echo
'-elenco famiglie: '.implode(', ',$fkeys).'

'
;
for(
$a=0;$a<count($species);$a++) //scorro l'array
{
$fam=$fkeys[$a];
$gkeys=array_keys($species[$fam]);
echo
'<h2>'.($a+1).'.INIZIO ISPEZIONE ARRAY species.'.$fam.':</h2>';
echo
'-generi totali: '.count($gkeys).'
'
;
echo
'-elenco generi: '.implode(', ',$gkeys).'

'
;
for(
$b=0;$b<count($species[$fam]);$b++) //scorro l'array
{
$gen=$gkeys[$b];
echo
'<h3>'.($a+1).'.'.($b+1).'.INIZIO ISPEZIONE ARRAY species.'.$fam.'.'.$gen.':</h3>';
echo
'-specie totali: '.count($species[$fam][$gen]).'
'
;
echo
'-elenco specie: '.implode(', ',$species[$fam][$gen]).'

'
;
echo
'<h4>Inserimento...</h4>';
for(
$c=0;$c<count($species[$fam][$gen]); $c++) //scorro l'array
{
$specie=$species[$fam][$gen][$c];
$inserisci = @mysql_query("INSERT INTO ragni (Specie,Genus,Family,img) VALUES ('$specie','$gen','$fam','no')");
echo 
'<nobr>'.($a+1).".".($b+1).".".($c+1)." inserimento della specie $specie, di genere $gen, appartenente alla famiglia $fam nel database...";
if(
$inserisci)
{
echo 
'INSERIMENTO COMPLETATO CON SUCCESSO!</nobr>
'
;
$OK++;
}
else
{
echo 
'ERRORE QUERY DI INSERIMENTO!
'
;
$NO++;
}
}
}
}
}
}
}
echo
'<h1>Procedimento terminato: tutti i file sono stati esaminati e tutti i valori sono stati inseriti nel database.</h1>';
echo
'[b]Trasferimenti riusciti:[/b] '.$OK.';
'
;
echo
'[b]Trasferimenti falliti:[/b] '.$NO.';
'
;
?>
</div>
</body>
</html>