Reputation: 25
I am creating weblinks on my site using PHP. Why do this and not do it manually - because I am accessing link information that is pulled from a mysql database. The query pulls out the data fine, the only trouble I am having is creating a text string with a link.
Two variables; $Loc_Name is the text I want to display, $Loc_Web is the URL.
Now i found the following which puts in the URL fine, but this does not display the text in the $Loc_Name output. How can I display the $Loc_Name value for the $Loc_Web url?
$Web_Link = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $Loc_Web);
Please Note ereg functions have been deprecated
Upvotes: 0
Views: 236
Reputation: 4228
if $Loc_Web is just the url without html tags, why don't you use this?
echo "<a href='" . $Loc_Web . "'>" . $Loc_Name . "</a>"
Upvotes: 2