Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use fgets in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 131
    Comment on it

    Hello Reader's If you need to read a given file line by line then PHP will offer you to use Fgets to do.

    Lets see it's example as below:-

    $handle = fopen("yourfile.txt", "r");
    if ($handle) {
        while (($line = fgets($handle)) !== false) {
            // process the line read. you can make further code here
        }
    
        fclose($handle);
    } else {
        // error opening the file. show to user
    } 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: