0

この結果が得られたので、フォルダから最初の画像を抽出して最初の画像をクリアしたい

結果の例

http://i.i.com.com/cnwk.1d/i/tim/2012/07/12/Les_Horribles_Cernettes_in_1992_620x350.jpg
http://i.i.com.com/cnwk.1d/i/tim/2012/07/03/IBM-350-publicdomain_220x157.jpg
http://cbsdigitalmedia.112.2o7.net/b/ss/cbscbsnewscomatlantisuat/1/H.21--NS.png
http://dw.com.com/clear/c.gif
http://i.i.com.com/cnwk.1d/i/tim/2012/07/03/IBM-350-publicdomain_220x157.jpg
http://dw.com.com/clear/test2.gif
http://cbsdigitalmedia.112.2o7.net/b/ss/cbscbsnewscomatlantisuat/1/H.21--NS.png
http://dw.com.com/clear/test.gif

欲しい画像

http://dw.com.com/clear/c.gif
4

1 に答える 1

2

OK、それで私は実際にあなたの質問にかなり興味をそそられました..それで私は少し何かを思いついた...

$firstFile;

//This is the array with your URL values
$imgUrls[0] = "http://i.i.com.com/cnwk.1d/i/tim/2012/07/12/Les_Horribles_Cernettes_in_1992_620x350.jpg";
$imgUrls[1] = "http://i.i.com.com/cnwk.1d/i/tim/2012/07/03/IBM-350-publicdomain_220x157.jpg";
$imgUrls[2] = "http://cbsdigitalmedia.112.2o7.net/b/ss/cbscbsnewscomatlantisuat/1/H.21--NS.png";
$imgUrls[3] = "http://dw.com.com/clear/c.gif";
$imgUrls[4] = "http://i.i.com.com/cnwk.1d/i/tim/2012/07/03/IBM-350-publicdomain_220x157.jpg";
$imgUrls[5] = "http://dw.com.com/clear/test2.gif";
$imgUrls[6] = "http://cbsdigitalmedia.112.2o7.net/b/ss/cbscbsnewscomatlantisuat/1/H.21--NS.png";
$imgUrls[7] = "http://dw.com.com/clear/test.gif";

//This foreach loop goes through the array and checks the containing directory
foreach($imgUrls as $value){
    $urlParts = explode("/",$value);
    if($urlParts[count($urlParts)-2] == "clear"){
        $firstFile = $value;
        break;
    }
}

//After setting $firstFile as the Image URL, echo it out.
echo $firstFile;
于 2012-11-07T11:33:52.353 に答える