echo <p> tag

Hello,

I’m using this tutorial to get images from flickr feed http://net.tutsplus.com/tutorials/php/create-a-slick-flickr-gallery-with-simplepie/

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]

<?php //get the simplepie library require_once('inc/simplepie.inc'); //grab the feed $feed = new SimplePie(); $feed->set_feed_url('http://api.flickr.com/services/feeds/photos_public.gne?tags=johanesburg&lang=en-us&format=rss_200'); //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): ?>
										<li>
		    			
		      			
		                    <?php
		                        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>
										</li>
										<?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);

}

[/php]

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!
Cheers

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="http://www.flickr.com/photos/probaditademexico/4772857514/in/set-72157624321392349/">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="http://www.flickr.com/people/probaditademexico/">Probadita De Mexico</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/probaditademexico/4772857514/" title="La llegada de Christian"><img src="http://farm5.static.flickr.com/4116/4772857514_2fdb7958a3_m.jpg" 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="http://www.flickr.com/photos/probaditademexico/4772857514/in/set-72157624321392349/">Read more&hellip;</a>
    <!-- end articlebody --><><>
<!-- end article --><>




Thank you!

Sponsor our Newsletter | Privacy Policy | Terms of Service