Advertisement
Guest User

Untitled

a guest
Feb 14th, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2.  
  3. function get_data_simple($source_file = 'source.txt')
  4. {
  5.     $file_size = filesize($source_file);
  6.     $source_fh = fopen($source_file, 'r');
  7.    
  8.     do {
  9.         fseek($source_fh, rand(0, $file_size - 1));
  10.         fgets($source_fh);
  11.         $result = fgets($source_fh);
  12.     } while (!trim($result));
  13.    
  14.     fclose($source_fh);
  15.     return $result;
  16. }
  17. $data = get_data_simple();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement