improve string catching of html page

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi all gurus in tha club,
I scripted a prog that extract a string from an html page excluding
all the tags.
The problem is that it works quite slowly and I wanted to know if
somebody of us as an idea how to improve his performance.

Thanks a lot


$start="start_str"; //begin string
$end="end_str"; //end string
if($snoopy->fetch(" ";)) //get the html

$string=$snoopy->results; //assign to $string all the html string

- Hide quoted text -
$line = explode("\n", $string); //trim the html in lines

while ($i<300)
//take only the middle
if ($i>230)     {
//explode the line to control the content
$piece = explode(" ", $line[$i]);

while ($k<200) {

//if it content the string that i'm searching... :)
if ($piece[$k] == "interesting_part") {

$word=preg_split("/[\s<>]+/", $line[$i]); //to eliminate html tags

$flag=0; //to say when print the word

//extract the string without html
while ($word[$j]) {

if ($word[$j] == $begin)        $flag = 1;
if ($word[$j] == $stop)          $flag = 0;
if ($flag)      echo "$word[$j] ";


Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

Re: improve string catching of html page

Sheela wrote:
Quoted text here. Click to load it

   I haven't closely looked at your code. But, looks like:
echo strpos(strip_tags(file_get_contents(' /')),
'to search');

  <?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com    Blog: /

Site Timeline