seguente codice viene utilizzato per trovare url da una stringa con php. Ecco il codice:Trova url da stringa con php
$string = "Hello http://www.bytes.com world www.yahoo.com";
preg_match('/(http:\/\/[^\s]+)/', $string, $text);
$hypertext = "<a href=\"". $text[0] . "\">" . $text[0] . "</a>";
$newString = preg_replace('/(http:\/\/[^\s]+)/', $hypertext, $string);
echo $newString;
Beh, si vede un collegamento, ma se posso fornire qualche collegamento non funziona e anche se scrivo senza http: // allora non mostra collegamento. Voglio che qualunque link sia fornito dovrebbe essere attivo, come StackOverflow.com.
Qualsiasi aiuto per favore ..
possibile duplicato di [PHP: espressioni regolari per ottenere un URL da una stringa] (http://stackoverflow.com/questions/2720805/php -regular-expression-to-get-a-url-da-a-string) – Gordon