function getImg($str){
$str = stripslashes($str);
$pattern = "/<img[^>]*src\=\"(([^>]*)(jpg|gif|png|bmp|jpeg))\"/i"; //获取所有图片标签的全部信息
preg_match_all($pattern, $str, $matches);
return $matches[1]; //$matches[1]中就是所想匹配的结果,结果为数组
}
$str = <<<EOT
Money has been moving into Brazilian stocks over the last couple of days, despite mostly flat trading activity in the U.S. equity markets. During Thursday's session, the iShares MSCI Brazil Index ETF (NYSE: EWZ) has risen 1.12% after outperforming the U.S. indices yesterday as well.
Must Read
SonySony Playstation Phone Rumors Heat Up
A South Korean Army soldier walks up steps of a guard post near the demilitarised zone separating the two Koreas.S. Korea waves olive branch
<img width="1" height="1" alt="" src="http://img.ibtimes.com/www/site/us/images/1px.gif" sized="yes">
Two giant resource companies make up a big chunk of the Brazilian Bovespa. They are PetroBras (NYSE: PBR), with a market cap of $163.44 billion, and miner Vale (NYSE: VALE), which has a market cap of $178.95 billion. PBR shares have risen 1.47% thus far today and VALE is trading 0.77% higher at $34.03.
<img alt="Sony" src="http://img.ibtimes.com/www/thumb/mainpage/13463-12079-sony.jpg" sized="yes">
This article was originally published on Benzinga, and is republished here with permission.
EOT;
foreach( getImg($str) as $url)
{
get_photo($url);
}