这是我的代码:
$post = $_POST['test'];
$pattren='/((([http]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\/+=&#?;%@,.\w_]*)#?(?:[\w]*)?))/';
preg_match_all( $pattren, $post, $matches);
foreach($matches[0] as $match) {
$images[]= "<a href=\"$match\" target=\"_blank\" >$match</a> ";
}
for ($i = 0, $c = count($images); $i < $c; $i++) {
$html_links = str_replace($pattren,$images[$i], $post);
}
echo $html_links;
我正在尝试从中获取所有 url$post
并将它们转换为链接,但是出了点问题。