Navigation :

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




Site Sponsors :

Bookmark :

Links :

dropshippers
wwwstores
finance products

Downloads :

Misc :

Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Search a text file

Find a pattern in a text file

<?php
//find a match in a file
//our pattern
$pattern = "html";
//open the websites file for reading
if(!$fp = fopen("websites.txt","r"))
{
echo "cannot open the file";
}
else
{
//while the file is not empty
while(!feof($fp))
{
//read a line at a time to try and find a match
$read_line = fgets($fp,255);
if($read_line == $pattern)
echo "We have a match<br>";
}
fclose($fp);
}
?>