note 105913 added to function.echo
| From: | apandy3 at gmail dot com | Date: | Sun, 25 Sep 2011 07:07:07 +0000 |
| Subject: | note 105913 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183414@lists.php.net to get a copy of this message | ||
Clickable links can be made with echo function. Look at the example below:
<?php
function makeClickableLinks($text) {
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'\\1<a href="http://\\2">\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
'<a href="mailto:\\1">\\1</a>',
$text);
return $text;
}
// Usage
// Email address example
$text = "name@show-ip.org";
echo makeClickableLinks($text);
echo "<br /><br />";
// URL example
$text = "http://www.show-ip.org";
echo makeClickableLinks($text);
echo "<br /><br />";
// FTP URL example
$text = "ftp://ftp.show-ip.org";
echo makeClickableLinks($text);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 182.178.35.48
----
Manual Page -- http://www.php.net/manual/en/function.echo.php
Edit -- https://master.php.net/note/edit/105913
Del: integrated -- https://master.php.net/note/delete/105913/integrated
Del: useless -- https://master.php.net/note/delete/105913/useless
Del: bad code -- https://master.php.net/note/delete/105913/bad+code
Del: spam -- https://master.php.net/note/delete/105913/spam
Del: non-english -- https://master.php.net/note/delete/105913/non-english
Del: in docs -- https://master.php.net/note/delete/105913/in+docs
Del: other reasons-- https://master.php.net/note/delete/105913
Reject -- https://master.php.net/note/reject/105913
Search -- https://master.php.net/manage/user-notes.php