//Define what you want the seperator to be, this could be new line, (\n) a tab (\t) or any other char, for obvious reasons avoid using chars that will be present in the string. Id suggest a comma, or semicolon. $sep = ","; //define file to read $file = "ktkz.txt"; //read the file into an array $lines = file($file); //count the array $numlines = count($lines); //explode the first (0) line which will be the header line $headers = explode($sep, $lines[0]); //count the number of headers $numheaders = count($headers); $i = 0; //start formatting output echo "\n
\n"; echo "\n"; echo "\n\n| cells while($i<$numheaders){ $headers = str_replace("\"", "", $headers); echo " | ".$headers[$i]." | "; $i++; } echo "
| ".$fields[$x]." | "; $x++; } $y++; echo "