Question: I am using file\_get\_contents() to import a text file.
In the text file, the format goes as below (example):

3434,83,8732722  

834,93,4983293  

9438,43933,34983  

and so forth... basically it follows the pattern: integer, comma to split it, second integer, another comma to split it, third integer, then a new line begins. I need to get this into a table with the format following accordingly. So in other words, I would have a 3 column table and each new line in the text file would be a new row in the table.

This must be transcoded into a simple html table with <table> <tr> and <td>

I have never worked with multidimensional arrays and splitting text with that. This is why I'm seeking assistance. I really appreciate it! :)

Answer: 
You can do following :

```
$filename = 'abc.txt';
$content = file_get_contents($filename);
$explodedByBr = explode('<br/>', $content);
$table = "<table border='1'>";
foreach ($explodedByBr as $brExplode) {
  $explodedByComma = explode(',', $brExplode);

  $table .= "<tr>";
  foreach ($explodedByComma as $commaExploded) {
    $table .= "<td>" .$commaExploded. "</td>";
  }
  $table .= "<tr/>";
}
$table .= "</table>";

echo $table;

```

abc.txt has data in following format :

3434,83,8732722   

834,93,4983293   

9438,43933,34983
```
<?php
    $file = 'path/to/file.txt';
    echo '<table>';
    while(!feof($file)) {
        $line = fgets($file);

        echo '<tr><td>' . implode('</td><td>',explode(',',$line)) . '</td></tr>';
    }
    echo '</table>';
?>

```