RE: [PHP] transforming an HTML Comment in a HTML TAG
| From: | Jason Murray | Date: | Mon, 15 Jan 2001 03:24:32 +0000 |
| Subject: | RE: [PHP] transforming an HTML Comment in a HTML TAG | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-34549@lists.php.net to get a copy of this message | ||
> So, before the end HTML comment I would like to add an image.
> How do I do that?
The first thing I suggest you do is use a comment for starting and a
comment for ending - this makes it all a LOT easier to parse.
Start: <!-- TEXT STARTS -->
End: <!-- TEXT ENDS -->
Then, you get your complete text into $buffer and just:
<?
$endtag = "<!-- TEXT ENDS -->";
$imgtag = " <a href='edittext.php?pageid=X'>"
."<img src='images/edit_buttom.gif'></a>";
$output = ereg_replace($endtag, $imgtag.$endtag, $buffer);
?>
... or something similar. Not sure if < or > or ! play havoc with a
regex or not...
If you can't change your start and end comments to be unique, then
you'll have to just do the ereg_replace on every second one.
Jason
--
Jason Murray
jasonm@melbourneit.com.au
Web Design Team, Melbourne IT
Fetch the comfy chair!