jaay Posted April 26, 2010 Share Posted April 26, 2010 I have a string where some simple html is stored. Here's the example <a href=http://someurl.com>Anchor Text1</a>, <a href=http://someurl.com>Anchor Text2</a>, <a href=http://someurl.com>Anchor Text3</a> Now, I need only the anchor text part not the <a> tags or the url within it. How to do it in PHP? Link to comment https://forums.phpfreaks.com/topic/199853-query-about-strings/ Share on other sites More sharing options...
JAY6390 Posted April 27, 2010 Share Posted April 27, 2010 Two options. Either via the DOM http://www.jaygilford.com/php/php-dom-get-all-pagelinks/ or using regex http://www.jaygilford.com/php/common-questions/how-to-get-all-links-from-a-web-page/ Link to comment https://forums.phpfreaks.com/topic/199853-query-about-strings/#findComment-1049034 Share on other sites More sharing options...
teamatomic Posted April 27, 2010 Share Posted April 27, 2010 explode it on the comma to an array then loop using this: preg_match('@(?:http://).*>(.*?)</a>@i', $string, $matches); HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/199853-query-about-strings/#findComment-1049041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.