想把一个html文件倒序输出,刚准备用C,想起来自己本地服务器架设好了,不如用php写一个。
观察了文件,发现每次<~/[nobug]div>可以做为每节的分割符,于是写了下面这个。 效果还不错,见另一篇。
当然<~/[nobug]div>这个是什么大家都知道的啦- -
$file=fopen("test","r") or exit("Unable to open file!");
function writeupdown($file)
{
$txtup="";
while (!feof($file))
{
$txtup2=fgetc($file);
$txtup=$txtup.$txtup2;
$txtadd=(strpos($txtup,"")-0);
if ($txtadd>0)
{
writeupdown($file);
break;
}
}
echo $txtup;
}
writeupdown($file);
fclose($file);
先全部用零减本身,先用sort()排着嘛,排好了,再用零减回本身就OK啦