How to make a text field linkable |
[eluser]margsot[/eluser]
I am using a text field in my database which stores the website url of a user, and this code to view this field on the page. Code: <?php echo $userDetails['website']; ?> What i want is to make this field linkable in _blank window I tried to insert a tag before the code above but doesnt work Any solution? Thanks
[eluser]SmokeyJoe[/eluser]
if $userDetails['website'] is like http://www.somewebsite.com Code: <a href="<?php echo $userDetails['website']; ?>" target="_blank"><?php echo $userDetails['website']; ?></a> should work Code: <?php echo anchor($userDetails['website'],$userDetails['website'],'target="_blank"'); ?> so you just have to check via regular expression if $userDetails['website'] has a correct format Code: if(preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $userDetails['website'])) |
Welcome Guest, Not a member yet? Register Sign In |