Jump to content

How can I extract part of a string, to print it?


SCordell

Recommended Posts

Hello,

I am a designer that is new to PHP. My question is: how can I extract part of a string, to print it?

 

For example, I have this string:

 

<td align="center" valign="center" style="padding:0" class="flickr_badge_image" id="flickr_badge_image1"><a href="http://www.flickr.com/photos/user/1553388976/in/set-62157605447604283/"><img src="http://farm4.static.flickr.com/3165/1553388976_68b023e8f4_m.jpg" alt="A photo on Flickr" title="Another Win" height="180" width="240"></a></td>

 

And from the above string, I only want to extract this portion:

 

<a href="http://www.flickr.com/photos/user/1553388976/in/set-62157605447604283/"><img src="http://farm4.static.flickr.com/3165/1553388976_68b023e8f4_m.jpg" alt="A photo on Flickr" title="Another Win" height="180" width="240"></a>

 

What code can I use to tell PHP to get everything in between "<a href" and "a>" and only print that? I've tried "substr" and "preg_match" and "preg_match_all"... but it's clear that I do not know what I am doing.

 

Thank you in advance for any help,

SC

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.