Справочники, инструменты, документация

reading-from-csv

reading-from-csv

index.php

<?PHP
$template = file_get_contents("template.html");
$f = fopen( "data.csv", "r" ) or die( "Ошибка!" );
echo "<table>\n";
$html = "";
for ( $i = 0; $data = fgetcsv( $f, 2048, "|" ); $i++ )
{
 $num = count( $data );
 if ( $num == 1 and $data[0] === "" ) continue;
 $row = $template;
 $row = str_replace("{title}", $data[0], $row);
 $row = str_replace("{description}", $data[1], $row);
 $row = str_replace("{rating}", $data[2], $row);
 $row = str_replace("{registration}", $data[3], $row);
 $row = str_replace("{faq}", $data[4], $row);
 $html = $html . $row;
}
fclose( $f );
echo $html;
echo "</table>\n";
?>

template.html

<tr>
 <td colspan="3">{title}</td>
</tr>
<tr>
 <td colspan="3">{description}</td>
</tr>
<tr>
 <td>{rating}</td>
 <td>{registration}</td>
 <td>{faq}</td>
</tr>

Скачать пример