DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

PHP READ TAB SEPARATED FILE

12.22.2005
| 9615 views |
  • submit to reddit
        // OPENS A TAB SEPARATED FILE
// PUTS DATA INTO AN ARRAY AND SPLITS IT BY TAB
// LOOPS THROUGH CODE AND PRINT

<?php

$filename = "Book1.txt";
$fd = fopen($filename,"r");
$contents = fread ($fd,filesize ($filename));
fclose($fd);

$splitcontents = explode(" ", $contents);
$counter = 0;

foreach($splitcontents as $data){
	echo $counter++;
	echo ":  " . $data;
	}


?>