delimited files using PHP
Trying to read a comma delimited file in PHP. Below is what I have so far. Can't seem to get it to print the contents of the file, before or after the separation.
I am new at this and am trying to separate this file as part of a small project I'm working on. I need this piece of the puzzle, though.
Thanks
<?php
$filename = "c:\commafile.txt";
$fd = fopen ($filename, "r");
$contents = fread ($fd, "25");
fclose ($fd);
$delimiter = ",";
$splitcontents = explode($delimiter, $contents);
$counter = "";
?>
Complete File Contents
<?
echo $contents;
?>
<br> <br>
Split File Contents
<?
foreach( $splitcontents as $color)
{
$counter = $counter+1;
echo "<b>Split $counter: </b> $colorn<br>";
}
?>
|