[英]Displaying the picture on the browser
以下代碼返回必須顯示的圖片的網址:
$link = "http://example.com/ext/lib/exe/process.phpt=87458+52&w=466&h=471&:forum_pic:queue_hasb_bunny_khd_tyun_02300.jpg, Imm processing,http://example.com/storage/high resolution/i-white bunny-tyun.jpg,only cash payment,process after christmas, handle with care notification, date: 2-5-2015";
$extraFieldData = explode(',',$link);
$images= array();
foreach($extraFieldData as $efd){
if(strpos($efd,'jpg')!== false){
$images[] = $efd;}
}
foreach ($images as $i){
echo $i;
}
<img src= "<?php echo $i;?>"/>
該代碼可以很好地響應圖片的網址,但是當我嘗試在瀏覽器中顯示網址時,僅顯示一張圖片,而不顯示另一張。 如何同時顯示兩個網址?
如果它僅顯示一張圖像(並且圖像URL正確),則說明您正在循環外執行該操作,並且$i
具有從$images
數組迭代的最后一個圖像的值。
例如:
$arr = ['one', 'two', 'three', 'four'];
foreach($arr as $a) {
}
echo $a;
這將輸出four
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.