Zend - The PHP Company




Files and Directories

Add Code


Match line  

Type: code fragment
Added by: robf
Entered: 21/03/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 6472
return the first line in a given file containing the given string


<?php
function getline($file$string) {

    
/* return the first line in a given file containing the given string */

    
$file_pointer fopen("$file""r");

    for (
$i 0; !feof($file_pointer); $i++) {
        
$line fgets($file_pointer1024);

        if (
ereg($string$line))
            break;

    }

    
fclose($file_pointer);

    return 
$line;
}  
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories