djneel Posted November 13, 2006 Share Posted November 13, 2006 Hello everyone,How can I turn this:[code]$title = "<h2><a href="index.html">The Index Page</a></h2>";[/code]Into this:[code]$urlFromTitle = "index.html";[/code]I just don't understand the PHP manual.Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/27129-extracting-an-url-out-of-a-string/ Share on other sites More sharing options...
blear Posted November 13, 2006 Share Posted November 13, 2006 You need the explode() command.array explode ( string delimiter, string string [, int limit] )So,[code]$title = "<h2><a href="index.html">The Index Page</a></h2>"; //This assignment statement wont work$kapow=explode('href="',$title);$secondBlast = explode('"',$kapow[1]);$urlFromTitle=$secondBlast[0];[/code]The $title assignment line wont work, so I'm guessing you have that string assigned in some other way. Link to comment https://forums.phpfreaks.com/topic/27129-extracting-an-url-out-of-a-string/#findComment-124026 Share on other sites More sharing options...
djneel Posted November 13, 2006 Author Share Posted November 13, 2006 Off course, how silly of me...[code]$title = "<h2><a href=\"index.html\">The Index Page</a></h2>";[/code]Thank you very much!It worked like a charm! Link to comment https://forums.phpfreaks.com/topic/27129-extracting-an-url-out-of-a-string/#findComment-124039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.