yarito Posted August 16, 2007 Share Posted August 16, 2007 Hi PHPFreaks, I've got this little function I wrote which converts links in my custom-built CMS. By using the Id of the page to link to, I can easily make an internal link to my own website, such as: A link: <link=1>this is a link</link> My function: function convert_Links($content) { $pattern='(<link=)([0-9]{0,5})(>)'; $replacement='<a href="/index.php?id=\2">'; $pattern2='</link>'; $replacement2='</a>'; $content=eregi_replace($pattern2, $replacement2,eregi_replace($pattern, $replacement, $content)); return $content; } which creates a nice link to: index.php?id=1 or whatever. However, I've recently changed to showing my urls using Mod-rewrite, so it would now show as: /products/product-number-5/1 (where the '1' on the end is the page Id) Is there any way to get this url using my function, rather than just the Id? To do this I'd need to extract the id, call another function to look up this page's url, then pass that back to the function. Help! I've been stuck on this for 6 months... Quote Link to comment https://forums.phpfreaks.com/topic/65334-eregi_replace-to-find-id-url/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.