Codice PHP:
<?php
$rr = 'http://biodizionario.it/images/semafori/rr.gif';
$r = 'http://biodizionario.it/images/semafori/r.gif';
$g = 'http://biodizionario.it/images/semafori/g.gif';
$v = 'http://biodizionario.it/images/semafori/v.gif';
$vv = 'http://biodizionario.it/images/semafori/vv.gif';
$filer = fopen("bio_format.txt", "w");
$file = fopen("bio.txt", "r");
while (!feof($file)) {
$buffer = fgets($file, 4096);
$pos = stripos($buffer,$rr);
if ($pos) $s = "RR; ";
$pos = stripos($buffer,$r);
if ($pos) $s = "R; ";
$pos = stripos($buffer,$g);
if ($pos) $s = "G; ";
$pos = stripos($buffer,$v);
if ($pos) $s = "V; ";
$pos = stripos($buffer,$vv);
if ($pos) $s = "VV; ";
preg_match_all("#[b](.*)[/b][[:space:]]{1,}(.*)<br \\/>#", $buffer, $match);
$s = $s . $match[1][0] . ";" ;
$s = $s . $match[2][0] . ";" . "\r\n";
fwrite($filer, $s);
}
fclose($file);
fclose($filer);
?>
Prova così