Report new bug | New search | Development Roadmap Status: Open | Feedback | All

Request #9789 feature request - makelinks() function
Submitted: 2007-01-09 22:16 UTC
From: pgl at instinct dot org Assigned:
Status: Bogus Package: PEPr
PHP Version: 5.2.0 OS: All and any
Roadmaps: (Not assigned)    
Subscription  


 [2007-01-09 22:16 UTC] pgl at instinct dot org (Peter Lowe)
Description: ------------ Re: http://bugs.php.net/bug.php?id=6893 Last comment (from bjori@php.net) was: "Please file PEAR/PECL related issues in the PEAR/PECL bug tracker." So, I am doing so. Here is the original bug report / feature request: --8<-- I don't know if this is the best way to submit a feature request, but I think it would be handy to have a builtin makelinks() function, to change all urls in a piece of text to actual links. eg, changing "my homepage is at http://www.arse.net/" to "my homepage is at <a href=http://www.arse.net/>http://www.arse.net/</a>". 'course, it's pretty easy to code this yourself, but then so is nl2br(), and having it as part of the source would (maybe?) make it faster. --8<-- Cheers, - Peter PS: Apologies if this is not the correct area to submit feature requests. It wasn't clear from http://pear.php.net/bugs/ where was the best place. Test script: --------------- <? $txt = "Hi! My homepage is at http://pgl.yoyo.org/."; $html = makelinks($txt); echo $html /* Outputs: --8<-- Hi! My homepage is at <a href="http://pgl.yoyo.org/">http://pgl.yoyo.org</a>. --8<-- */ ?> Expected result: ---------------- Hi! My homepage is at <a href="http://pgl.yoyo.org/">http://pgl.yoyo.org</a>.

Comments

 [2007-01-10 05:30 UTC] cellog (Greg Beaver)
What you need is a simple regular expression to grab urls and then encase them in <a href="\\1">\\1</a> using preg_replace. This is a 2-line piece of code, and so does not belong as a complete PEAR package. if you wish to propose a new package for PEAR that includes string manipulation, feel free, http://pear.php.net/pepr