I am stuck on what should be a very simple script. I am reading a very large file and writing it to 8 smaller ones. The program runs, but the constant record length of 237 seems to be off. The last_name for example should start in position 21, but the new files have it in 19. The basic code follows.
(Preliminary code not shown)
$storedrecord = fgets($fp,237);
echo "$storedrecord<br>";
if ($storedrecord[5] == 1)
{
fwrite($fp1,$storedrecord);
}
if ($storedrecord[5] == 2)
{
fwrite($fp2,$storedrecord);
}
if ($storedrecord[5] == 3)
{
fwrite($fp3,$storedrecord);
}
if ($storedrecord[5] == 4)
{
fwrite($fp4,$storedrecord);
}
if ($storedrecord[5] == 5)
{
fwrite($fp5,$storedrecord);
}
if ($storedrecord[5] == 6)
{
fwrite($fp6,$storedrecord);
}
if ($storedrecord[5] == 7)
{
fwrite($fp7,$storedrecord);
}
if ($storedrecord[5] == 8)
{
fwrite($fp8,$storedrecord);
}
Again, this runs, but does not get the full length of each line & "skews" the positions. Any help would be appreciated.
Howard