echo <p> tag


I’m using this tutorial to get images from flickr feed

But I want to display the description of the image wich is buried deep inside the description of the feed. it is inside the third

tag how do I echo it?

Thank you

You can use preg_match() to extract information from a string. Can you post here sample content, and describe what you need to parse/extract there?

It’s going to be a lot of code but here it goes


<?php //get the simplepie library require_once('inc/'); //grab the feed $feed = new SimplePie(); $feed->set_feed_url(''); //enable caching $feed->enable_cache(true); //provide the caching folder $feed->set_cache_location('cache'); //set the amount of seconds you want to cache the feed $feed->set_cache_duration(3600); //init the process $feed->init(); //let simplepie handle the content type (atom, RSS...) $feed->handle_content_type(); ?>
		<?php if ($feed->error): ?>
				  <p><?php echo $feed->error; ?></p>
				<?php endif; ?>
<?php foreach ($feed->get_items(0, 10) as $item): ?>
		                        if ($enclosure = $item->get_enclosure()) {
		                            $img = image_from_description($item->get_description());
		                            $full_url = select_image($img, 4);
		                            $thumb_url = select_image($img, 3);
		                            echo '<a href="' . $full_url . '" class="lightbox" title="' . $enclosure->get_title() . '"><img class="photo-main' . $i . '" src="' . $thumb_url . '" /></a>'."\n";
							<h5 style="background:url(<?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?>) no-repeat; text-indent: 25px; margin: 10px 0 10px;"><?php echo$item->get_title(); ?></h5>
										<?php endforeach; ?>

function image_from_description($data) {
preg_match_all(’/<img src="([^"])"([^>])>/i’, $data, $matches);
return $matches[1][0];

function select_image($img, $size) {
$img = explode(’/’, $img);
$filename = array_pop($img);

$s = array(
    '_s.', // square
    '_t.', // thumb
    '_m.', // small
    '.',   // medium
    '_b.'  // large

$img[] = preg_replace('/(_(s|t|m|b))?\./i', $s[$size], $filename);
return implode('/', $img);



Now I need to extract the third

tag from the xml description

I’m lost

Thanks for the help!

Hey Guys, any ideas on this…I still can’t figure it out.

Thank you

I can only see the one

tag in there so am not sure where you mean but if I understand you right then could you not use $item->get_description() inside the foreach loop to show the description?

If you see the rss flickr code inside the description There are 3

tags , one contains the name of the user with a link, then the photo, and then the description of the photo ( wich is what we want ) if we use get_desrciption we get all 3 items. I used jQuery to get the result I wanted but I kindda wanted to learn a bit more PHP.

Thank for answering though!

I’ve looked through the code again and I still don’t see 3

tags are you talking about the code output in a browser? if so if you could provide a link we might be able to give you a php way of doing what you want.

Here’s the Rss feed flickr gives with a buch of apple stuff from the safari source code. I tried setting apart the

tags using some spaces

<div class="apple-rss-subject" title="La llegada de Christian"><a href="">La llegada de Christian</a><>
        <div class="apple-rss-author" title="Probadita De Mexico">Probadita De Mexico<>
        <div class="apple-rss-summary" >Probadita De Mexico posted a photo:  Christian, nuestro niño Teletón, fue recibido por el Mariachi<>
        <div class="apple-rss-date" title="Today, 6:20 PM">Today, 6:20 PM<>
   <div class="apple-rss-article-body-container">
    <div class="apple-rss-article-body">

    <p><a href="">Probadita De Mexico</a> posted a photo:</p>
<p><a href="" title="La llegada de Christian"><img src="" width="240" height="159" alt="La llegada de Christian" /></a></p>
<p>Christian, nuestro niño Teletón, fue recibido por el Mariachi</p>

&nbsp;<a class="apple-rss-article-link" href="">Read more&hellip;</a>
    <!-- end articlebody --><><>
<!-- end article --><>

Thank you!

Sponsor our Newsletter | Privacy Policy | Terms of Service