You are here: Re: Help taking a string from a file « PHP « IT news, forums, messages
Re: Help taking a string from a file

Posted by "M. Sokolewicz" on 01/14/06 20:26

Lists wrote:
> Hello List,
>
> I made something work, but probably in the most crappy way possible.
>
> My goal is to take just the HTML for the image and link from the Flickr
> badge js script.
>
> This is what I did, please help me do in a better way. I'd appreciate
> good sources to read to learn to strip stuff away and just get specific
> parts as well. I never know which of the str functions to use.
>
> <?
> // allow retrieval of external web source
> ini_set('allow_url_fopen',1);
>
> // get flickr js file
> $photo = file_get_contents("http://www.flickr.com/badge_code_v2.gne?
> count=1&display=latest&size=m&layout=h&source=user&user=91667218% 40N00");
>
> //get rid of all the crap except for the image tags
> $photo = strstr($photo, '<a');
> list($image, $trash) = explode("'", $photo);
> $image = ereg_replace("</td>","", $image);
> ?>

why not just do:

$file =
file_get_contents('http://www.flickr.com/badge_code_v2.gne?count=1&display=latest&size=m&layout=h&source=user&user=91667218%40N00');

preg_match('#<img (.*)src="(.+)"#U', $file, $r);
$photo = $r[2];

?
- tul

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация