Looping or what?
| From: | Zac Hillier - Net Affectors | Date: | Wed, 09 Jul 2003 13:12:30 +0000 |
| Subject: | Looping or what? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-154541@lists.php.net to get a copy of this message | ||
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;