i got it all working now!!! huh!
but my problem is, why is it when there's always a blank data being displayed?
<?php
$fp = @fopen("studlst.txt", "r") or die("Couldn't open file");
$data = @fread($fp, filesize($fp));
while(!feof($fp))
{
$data .= @fgets($fp);
}
fclose($fp);
$values = explode("\n", $data);
foreach ($values as $val)
{
$read = sscanf($val,"%24s %s %d %s %s %s");
echo $read[2]." - ".$read[5];
echo ("<br />");
}
?>
here's the result code...
JJO Cust
============
127119 - I021258
127121 - I017812
127195 - I021275
127327 - I010898
127522 - I019835
127630 - I004060
127638 - I021344
127641 - I016019
127644 - I018246
127697 - I019553
127701 - I020584
127718 - I019415
127724 - I021357
127725 - I019912
127727 - I018056
127730 - I016662
127736 - I021359
127741 - I013305
127749 - I018504
127751 - I020617
127753 - I005730
127765 - I003125
127767 - I021361
127768 - I021362
127773 - I014573
127780 - I017331
127785 - I017953
127794 - I018925
-
NOTE: try to look on the " - " being generated as well... it should not be like this because if i will insert this to my database it will produce an error, right? because my field is set to "NOT NULL"
pls. help me... thanks!
help in my fixed-width text file & php
Moderator: General Moderators
-
mfmondragon
- Forum Newbie
- Posts: 4
- Joined: Sat Jan 27, 2007 12:17 am
<?php
$fp = @fopen("studlst.txt", "r") or die("Couldn't open file");
//$data = @fread($fp, filesize($fp)); <- not needed
while(!feof($fp))
{
$data[] = @fgets($fp);
}
fclose($fp);
foreach ($data as $val)
{
if (!empty($val))
{
$read = sscanf($val,"%24s %s %d %s %s %s");
echo $read[2]." - ".$read[5];
echo ("<br />");
}
}
?>
$fp = @fopen("studlst.txt", "r") or die("Couldn't open file");
//$data = @fread($fp, filesize($fp)); <- not needed
while(!feof($fp))
{
$data[] = @fgets($fp);
}
fclose($fp);
foreach ($data as $val)
{
if (!empty($val))
{
$read = sscanf($val,"%24s %s %d %s %s %s");
echo $read[2]." - ".$read[5];
echo ("<br />");
}
}
?>