Re: string comparison

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2008-07-13 at 21:47 +0530, Sudhakar wrote:
> hi
> 
> i am writing a small application where a user enters a phrase in the
> textfield and i would like to display all the files present in the root
> directory which consists of the keyword or keywords entered by the user.
> 
> i have used a few comparison functions but i am not getting the expected
> result.
> 
> $my_file = file_get_contents("filename.html");
> what ever the user enters whether it is a single word or few words i would
> like to compare with $my_file in a case insensitive manner.
> 
> can anyone suggest the best method and how to go about.

I don't suggest using file_get_contents. It would probably be more
efficient (at least less memory intensive) to use fopen() and fread().
Just be sure you overlap each read by $the_size_of_the_largest
phrase_or_keyword - 1. Then use stripos() for matching... of course that
won't work so well if whitespace doesn't need to match exactly in
phrases. In which case you'll need to resort to other techniques.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux