Hier werden alle URLs aus dem per Formular übergebenen String extrahiert.
<?php
if (isset($_POST['a'])) {
if (get_magic_quotes_gpc()){
$content = htmlentities(stripslashes($_POST['a']));
}
}
$success = preg_match_all('#(https?://[a-z0-9/.-]+)#i', $content, $matches);
if ($success){
$urls = $matches[1];
}else{
$urls = array(0);
}
$tmp = sort(array_unique($urls));
echo <<< EOT
<form action="{$_SERVER['PHP_SELF']}" method="post">
<textarea name="a">$content</textarea>
<input type="submit" value="berechnen">
</form>
<h2>URLs</h2>
EOT;
print '<ul>';
foreach ($urls as $url){
printf ('<li>%s</li>', $url);
}
print '</ul>';
?>