|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-03-15 18:29 UTC] ofjord at simnet dot is
I want to parse a HTML document to replace all links to .htm documents so that the .htm document becomes a parameter in a php script.
Here is the code to replace the links:
$text = eregi_replace("href=(\")?(.*[.]htm)(\"?)", "href=\\1template1.php?file=\\2\\3", $text);
This works fine, but only once in each document. This text:
<B>•</B> <a href="ferdatjon_fyrirt_gisting.htm">Gisting</a><BR><BR>
<B>•</B> <a href="ferdatjon_fyrirt_handverkshus.htm">Handverksh?s</a><BR><BR>
returns:
<B>•</B> <a href="template1.php?file=ferdatjon_fyrirt_gisting.htm">Gisting</a><BR><BR>
<B>•</B> <a href="ferdatjon_fyrirt_handverkshus.htm">Handverksh?s</a><BR><BR>
Is this a bug?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 07:00:01 2025 UTC |
Thank you for your advice. Now my regex code looks like this and works perfectly: $text = eregi_replace("href=(\")?([_/a-zA-Z0-9]*[.]s?html?)(\"?)", "href=\\1template1.php?file=\\2\\3", $text);