The code below is suppose to replace some images and links but when I run it
the page just seems to hang and eventually times out.

Am I Looping somewhere and not realising it?

Thanks

Zac

$i = $c01_1;
$imgLst = '';

function imgRplc($val){
 global $imgLst;
 global $i;
 $imgLst .= "<div class=\"figTtl\">Fig. $i</div><img src=\"$val[1]\" />,";

 return '<div class="fig">(Fig.'.$i.')</div>';
}

// first remove pics and add a reference to the end of the doc for those
that are required
while(preg_match("/<img type=\"reg\" src/",$disp)){

 $disp = preg_replace_callback("/<img type=\"reg\" src=\"(.+)\" alt=(.+)
\/>/i", 'imgRplc', $disp,1);
 $i++;

}

// now remove all other pics
$disp = preg_replace("/<img (.+) \/>/i", '', $disp);

// remove bigPic links  target="bigPic"
$disp = preg_replace("/<a (.+) target=\"bigPic\">(.+)<\/a>/i", '\\2',
$disp);

// next find shopping links and mark up
$disp = preg_replace("/<a href=\"(.+)\"(.*)>(.+)<\/a>/i", '<div
class="shpLnk">Link to: \\3 (Enter into your browser:
http://www.lasersailing.com\\1)</div>', $disp);

// remove paragraphs
$disp = preg_replace("/<\/p>(\s*)<p>/i", '<br /><br />', $disp);
$disp = preg_replace("/<p>/i", '', $disp);
$disp = preg_replace("/<\/p>/i", '', $disp);

echo $disp;



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

Reply via email to