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 Link to comment https://forums.phpfreaks.com/topic/75870-solved-substring-help/ 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 ; ?> Link to comment https://forums.phpfreaks.com/topic/75870-solved-substring-help/#findComment-384004 Share on other sites More sharing options...
ilkernyc Posted November 4, 2007 Author Share Posted November 4, 2007 thanks a lot! Link to comment https://forums.phpfreaks.com/topic/75870-solved-substring-help/#findComment-384641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.