PHP/File Directory/Text File

Материал из Web эксперт
Перейти к: навигация, поиск

Display contents of txt file to browser

 
<?
    $events = fopen("data.txt", "r");
    
    print "<table><tr><td><h3>Events:</h3>";
    while (! feof($events)) :
              $event = fgets($events, 4096);
              $event_info = explode("|", $event);
              print "$event_info[0] ( $event_info[1] ) <br>";
              print "<b>$event_info[2]</b> <br>";
              print "$event_info[3] <br> <br>";
    
    endwhile;
    print "</td></tr></table>";
    
    fclose ($events);
?>
File: data.txt
a|b|c|d|e