The following PHP should be able to do it; but there may be a catch 22 if the timeout is a file access issue rather than being related to the processing that you are doing. PHP will need write access to the current directory.
PHP Code:
<?php
$source = "file.txt";
$destination1 = "file_1.txt";
$destination2 = "file_1.txt";
// count the number of lines in $source
$lines = 0;
$fs = fopen($source,"r");
while(!feof($fs))
{
fgets($fs,1024);
$lines++;
}
// divide $count by 2 to get the halfway point
$count = intval($count / 2);
// rewind $source and open $destination1 & 2 for writing
rewind($fs);
$fd1 = fopen($destination1,"w");
$fd2 = fopen($destination2,"w");
$progress = 0;
while(!feof($fs))
{
$line = fgets($fs,1024);
$progress++;
if ($progress < $count)
{
fwrite($fd1,$line);
}
else
{
fwrite($fd2,$line);
}
}
fclose($fs);
fclose($fd1);
fclose($fd2);
?>
Bookmarks