ilkernyc Posted November 3, 2007 Share Posted November 3, 2007 Hi, i want to get the url string out of the href. For example this comes back from the database: a href="http://something.com" target="_blank" /a i want to get the substring "http://something.com" How do i do it? Thank you so much for your helps Note: Url's are in different lenghts in the database Quote Link to comment Share on other sites More sharing options...
MadTechie Posted November 3, 2007 Share Posted November 3, 2007 better to use RegEx.. see Regex Section example code <?php $html = '<a href="http://something.com" target="_blank">Test </a>'; if (preg_match('/href="([^"]*)"/i', $html , $regs)) { $result = $regs[1]; } else { $result = "No URL Found"; } echo $result ; ?> Quote Link to comment Share on other sites More sharing options...
ilkernyc Posted November 4, 2007 Author Share Posted November 4, 2007 thanks a lot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.