#1
  1. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    49
    Rep Power
    15
    Hi,

    I have looked for info concerning thios on mail archives etc., but there never seems to be any conclusive results. Is it possible to search for a given string in a series of HTML or text files using PHP ? If so, how do you do this ?

    cheers,

    Nick
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    Not sure what you want to do after you detect whether or not the string was found, or how many pages you will want to search but here it is for one page:
    $file = file("http://www.somewhere.com/somepage.html");
    $lines_string = implode( '', $file);
    if (eregi($seacrhstring, $lines_string)) {
    print "Search string found";
    }
    else {
    print "Search string not found";
    }
  4. #3
  5. No Profile Picture
    perspiration
    Guest
    Devshed Newbie (0 - 499 posts)
    ...and how about if one wants to perform a more complex search for multiple words on a variable number of pages where the text to be searched is only that which is visible to a web browser? In other words, a more fully-fledged search engine for a single web site using PHP? I assume in this case you'd need some sort of cron job to 're-index' your browser-viewable text, the output from which would be available for searching?
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by perspiration:
    ...and how about if one wants to perform a more complex search for multiple words on a variable number of pages where the text to be searched is only that which is visible to a web browser? In other words, a more fully-fledged search engine for a single web site using PHP? I assume in this case you'd need some sort of cron job to 're-index' your browser-viewable text, the output from which would be available for searching?[/quote]

    after extracting the html page and
    before performing your search
    you can strip html and php tags using the strip_tags command

    string strip_tags(string str, string [allowable_tags] );




    ------------------
    <A HREF="http://www.webempire.com.ph
    http://www.titikpilipino.com" TARGET=_blank>http://www.webempire.com.ph
    http://www.titikpilipino.com</A>

Similar Threads

  1. read iframe html.....write to form, string..etc.
    By dave777 in forum PHP Development
    Replies: 2
    Last Post: February 2nd, 2004, 10:11 AM
  2. Can php be used in html files
    By emzyme in forum PHP Development
    Replies: 3
    Last Post: January 29th, 2004, 01:50 PM
  3. seperate html tags from text in string
    By sweetpotatoe in forum PHP Development
    Replies: 3
    Last Post: January 28th, 2004, 10:39 AM
  4. need to search an html page in html
    By lwaa in forum HTML Programming
    Replies: 8
    Last Post: January 23rd, 2004, 09:07 PM
  5. Cgi Search feature script
    By butsy_7 in forum Perl Programming
    Replies: 5
    Last Post: January 22nd, 2004, 07:43 PM

IMN logo majestic logo threadwatch logo seochat tools logo