i need to make $with in Array to use it in preg_replace ??
foreach($matches[0] as $match) {
$sql = "insert into url values('$id','$match','$shorturl')";
mysql_query($sql,$con);
$with="<a href=\"http://127.0.0.1/url1/". $shorturl ."\">http://127.0.0.1/". $shorturl ."</a>";
}
$html_links = preg_replace('"\b(http://\S+)"',$with , $_POST['url']);
any help ?
You would want to use
preg_match_all(), to save the results in an array. Example:$matcheswill contain all the matches.Look in the documentation for more details:
http://php.net/manual/en/function.preg-match-all.php
EDIT: If you want to save the $with in an array, use the following: