rewind
-
The
rewindfunction in PHP resets the file pointer back to the start of the file. This example does a dummy read on the file to move the pointer and then rewinds it.PHP
$f = fopen('/path/to/foobar.txt', 'r'); fread($f); print ftell($f); //=> 42 rewind($f); print ftell($f); //=> 0 fclose($f);
Ruby’s
File#rewindmethod works exactly the same way.Ruby
File.open('/path/to/foobar.txt', 'r') do |f| f.read puts f.tell #=> 42 f.rewind puts f.tell #=> 0 end
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

