Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
File line ReversalCode Wizard, 12-30-2006 |
This script will reverse the lines in a file. So if you have something that is line based (some newscripts that use flat files) and need to reverse the file line by line for any reason, this will do it.
<?php
$fileLines = file("input.file"); #load file into a variable
$i = count($fileLines); #count the lines in the file
$cnt = $i; #change $i to $cnt
touch("output.file"); #create output file
$fp=fopen("input.file", 'r'); #load file into file pointer
for(;$cnt >= 0;$cnt--) #count down statment line by line loop
{
fputs ($fp,"$fileLines[$cnt]"); #put the line to the file
}
fclose($fp); #close file pointer's file
echo "Done Reversing."; #done!
?>
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

