<?php

error_reporting
(0);


function 
url_parser($str)
{
    
$pattern '`((http:\/\/|https:\/\/)(www.)?(([a-zA-Z0-9-]){2,}\.){1,4}([a-zA-Z]){2,6}(\/([-a-zA-Z%_\/\.\+0-9#:?=&;,]*)?)?)`i';
    
    
preg_match_all($pattern$str$matches);
    
$out $matches[0];
    
$out array_unique($out);
    
sort($out);
    
    return 
$out;
}


?>
<form action="" method="post">
<textarea cols="40" rows="7" style="width:98%" name="in"><?php echo $_POST['in'?></textarea><br />
<input type="submit" value="Parse !" />
</form>

<?php if(count($_POST)) : ?>
<?php    $urls 
url_parser($_POST['in']) ?>
<hr />
<h4><?php echo count($urls?> urls</h4>
<pre><?php echo implode("\n"$urls?></pre>
<?php endif ?>