PHP read TXT
February 21st, 2011 at 04:10pm Jason 53 views
Common Display:
<?php $file = 'data.txt'; $content = file_get_contents($file); echo $content; ?>
The line you want to show:
<?php $txt=file('data.txt'); echo $txt[3]; //It will show you line 4. because the beginning number is 0 ?>
Get the Random:
<?php $arr=file('data.txt');//txt name $n=count($arr)-1; for ($i=1;$i<=10;$i++){//Display 10 lines $x=rand(0,$n); echo $arr[$x],"\n"; } ?>
The Latest 20 lines:
<?php $a = file("data.txt"); $b = count($a); $c = $b-20; for($i=$c;$i<$b;$i++) { echo $a[$i]."\n"; } ?>
<?php $txt=file('data.txt'); echo implode("\n", array_slice($txt,-20,20)); ?>
Entry Filed under: Internet Tagged with: PHP txt
Hot Posts Hot Comments Hot Tags
- apartment bbpress blog class CMS code CSS div dream english friends girl Google hot Hot Dog html job JS life lines love Madonna menu Michael Jackson movie oral english PHP plugin saying school sexy site student students submenu success tags teacher teaching txt university video website widget wordpress





Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackback this post | Subscribe to the comments via RSS Feed