mars_rahul Posted December 16, 2007 Share Posted December 16, 2007 here is the actual code. <?php $string = $row['Body_html']; /*$string wiill contain : - <p><a href="http://www.thefullmonte.com">thefullmonte.com</a></p> I came to Afghanistan to cover the first-ever democratic elections with an American documentary film team. In the weeks leading to the Afghan elections the Taliban vowed bombings and kidnappings. However, the only excitement over the month of campaigning and Election Day was that from the Afghan people rallying for their candidates.<p>With a week left before I was to leave Afghanistan, I had planned a 3-day trek to Bamiyan with my colleague, John Monte, a cameraman. Kabul had become a fortress city where dwellings were not called homes or offices, but compounds with 2 to 3 guards holding AK-47s. There was a slight tension in the air. International security forces, ISAF, rumbled through the city in armored personnel carriers and Humvees swinging 70 caliber machine guns. And there was a constant buzz of Apache attack helicopters above.</p>*/ // from the above string i need to extract hyperlink (<a>) tag with its content. //output of above must be : -<a href="http://www.thefullmonte.com">thefullmonte.com</a> ?> please help me out Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 16, 2007 Share Posted December 16, 2007 Something like this: <?php if(preg_match_all("~<a href="(.*)">(.*)</a>~",$string,$matches)){ echo 'found matches:'; print_r($matches); }else{ echo 'no matches found'; } ?> 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.