Location: PHPKode > projects > urlmatch > urlmatch/_test.urlmatch.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<style type="text/css">
.mainText { 
	font-family: Verdana,Geneva,Helvetica; font-size: 13px; color: #999999; }
a.subclassExample:active, a.subclassExample:link, a.subclassExample:visited { 
	font-family: Verdana,Geneva,Helvetica; font-size: 13px; 
	color: #999999; text-decoration: underline; } 
a.subclassExample:hover { 
	font-family: Verdana,Geneva,Helvetica; font-size: 13px; 
	color: #999999; text-decoration: none; } 

<body bgcolor="#111111">
<span class="mainText" lang="en" xml:lang="en">


$url = array();
$url[] = "use this class to find a URL that appears http://google.com somewhere in text.";
$url[] = "the URL can also appear as www.google.com somewhere in text.";
$url[] = "it's all going to end soon, see http://www.google.com/search?hl=en&ie=ISO-8859-1&q=internet+impending+doom for yourself (example of long query strings, truncated to the length you set).";
$url[] = "ahh Brighton is such a beautiful place http://www.mapquest.co.uk/cgi-bin/ia_find?link=btwn/twn-map_results&event=find_select&search=[3-22]4+VICTORIA+ROAD,+BRIGHTON,+EN,+UK&uid=uagab4hbv2icgphc:y2haaxl47&lat=508271&lng=-1495&country=UK&level=9&style=3&width=390&height=245 (another example of an extremely long query string url)";
$url[] = "lots of subdomains -- http://lc2.law13.hotmail.passport.com/cgi-bin/login -- right here.";
$url[] = "also does secure (https://www.paypal.com/) sites (in parenthesis) or typed like above";
$url[] = "also does: ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.2.tar.gz";
$url[] = strip_tags("example with text processed by strip_tags(): (<a target=_blank href=\"http://yahoo.com\">http://yahoo.com</a>).  This is the ideal way to use the urlmatch class.");
$url[] = "same example of text with ".htmlspecialchars("<a>")." tag, unprocessed by strip_tags(): <a target=_blank href=\"http://yahoo.com\">http://yahoo.com</a>.  The source is untouched, but you can't match the same url if it appears un-tagged: http://yahoo.com.  As a workaround, it is ideal to use strip_tags() before urlmatch() and specify the tags you want to keep.";
$url[] = "example of detection within trailing HTML tags: <p>A paragraph.</p><p>Here's a URL with trailing html tags: http://www.yahoo.com</p>";
$url[] = "punctuation example: Have you ever used http://google.com?";
$url[] = "punctuation example: Have you ever used http://google.com!";
$url[] = "punctuation example: Have you ever used http://google.com.";
$url[] = "punctuation example: Have you ever used http://google.com, then http://yahoo.com?";
$url[] = "punctuation example: using http://google.com; using http://yahoo.com";
$url[] = "punctuation example: Have you ever used \"http://google.com\"";
$url[] = "punctuation example: Have you ever used 'http://google.com'";
$url[] = "punctuation example: Have you ever used (http://google.com)";
$url[] = "http://www.dopeman.com";
$url[] = "HTTP://WWW.DOPEMAN.COM";
$url[] = "current limitation of the class: can't process www urls when the same url appears in multiples with and without the url protocol (unless one of the urls has a different case): http://www.dopeman.com www.dopeman.com WWW.DOPEMAN.COM";
$url[] = "this works though: www.uofd.tv www.uofd.tv or www.newbirthusa.com www.newbirthusa.com";
$url[] = "this works too: duplicate urls appearing with trailing punctuation: www.uofd.tv, www.uofd.tv or www.newbirthusa.com, www.newbirthusa.com";
$url[] = "this works too: http://www.dopeman.com http://www.dopeman.com WWW.DOPEMAN.COM";
$url[] = "http://test_-chars9.test_-chars9.test_-chars9.com/";
$url[] = "http://nomatch/";
$url[] = "www.ot13.de.\r\nwww.url.com,\r\n(simulate PC line breaks)";

$u = new urlmatch();
$u->debug = FALSE;
$u->charLimit = 70;
$u->breakTxt = "...";
$u->startFromLeft = TRUE;
$num = 0;
foreach($url as $stringWithUrl)
	echo "<b>($num)</b> '", $u->match($stringWithUrl), "'\n<br /><br />\n\n";

$stringWithUrl = "<b>($num)</b> another example: www.righton.com";
echo $u->match($stringWithUrl,"you can also specify generic text for the matched link"),
																		"\n<br /><br />\n\n";

Return current item: urlmatch