PHP - Linking to a txt file to display information -


currently trying php.

i have txt file contains 3 entries of information, 3 titles information each section underneath. there way of pulling these details html page wording separated?

cheers

  • so works me, add more spacing between 3 sections, table.
' . $name . '

'; } fclose($handle); ?>

you can using fopen, fgets. extract 1 line @ time (two lines supposed separated new line character), explode it.

you can explode number of sections. in case there 3 sections, each separated |. code this:

<?php   error_reporting(0);    $document_root = $_server['document_root'];     $filename = $document_root."foldername/file.txt";     $fp = fopen($filename, 'r');     $m = 0;     echo "<table>       <tr>         <th>id</th>         <th>name</th>         <th>email</th>       </tr>";     while (true)     {       $m++;       $line = fgets($fp);       if (feof($fp)){         break;       }       list($id,$name,$email) = explode('|', $line);       echo "<tr>              <th>$id</th>              <th>$name</th>              <th>$email</th>             </tr>";     }     echo "</table>"; ?> 

if information 1 section not in single line nedd adjust loop accordingly.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -