text.php文件
-----------------
<pre>
<?php
$body = $_POST['url'];
 preg_match_all("/<a[^<>]+href *\= *[\"']?(http\:\/\/[^ '\"]+)/i", $body, $body_links, PREG_SET_ORDER);
 function test_print(& $item, $key)
{
   $item = htmlspecialchars($item);
}

array_walk_recursive($body_links, 'test_print');

var_dump($body_links );


?>

</pre>
<form method="POST" >
  <input name=url value="<?php echo htmlspecialchars ($body) ;?>" style="width:1000px;" />
  <input type=submit />
</form>--------------

结果图

获取a标签的href中的链接php正则_html