Home Tutorial Php Phpfiles PHP function rewind() and example

 
 

Share on Google+Share on Google+
PHP function rewind() and example
Posted on: October 30, 2009 at 12:00 AM
Advertisement
In this part of the tutorial we will learn about the function rewind in context of file handling. And also we will see the example related to the rewind function

PHP rewind() Function Syntax

bool rewind(file_handle)

  • In file handling the file pointer goes to other position after reading the file.
  • rewind() function is used to set the pointer at the beginning position in the file.


Example of PHP rewind() Function

<?php
    $file
=fopen("roseindia.txt","r");
    echo
"<br>file pointer position ".ftell($file);
    fgets($file);
    fgets($file);
    echo
"<br>file pointer position ".ftell($file);
    rewind($file);
    echo
"<br>after rewind file pointer position ".ftell($file);
?>

Output

  • file pointer position 0
  • file pointer position 345
  • after rewind file pointer position 0
Advertisement

Related Tags for PHP function rewind() and example :


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 30, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com