Simple View Helper for replacing links with A HREF
1
2
3
4
56
7
8
9
| <?php class Be_View_Helper_ClickableUris extends Zend_View_Helper_Abstract { public function ClickableUris($text = '') { $pattern = '#(^|[^\"=]{1})(http://|https://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm'; return preg_replace($pattern, "\\1<a href=\"\\2\\3\" target=\"_blank\"><u>\\2\\3</u></a>\\4", $text); } } |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
Replaces all "links" beginning with
http://
https://
ftp://
mailto:
news:
with a clickable link <a href="link">Link</a>
Snippet details
- Created:
-
Ben
- Edited:
-
Ben
- Revision Id:
- 166
- Edit Message:
- Initial Release
- ZF Version
- 1.10.0
- Tags:
- view helper view url uri
- Comments:
- 0
- Views:
- 3968
- Points:
- 0 (0 votes)