Created
June 16, 2016 16:00
-
-
Save Restoration/e242a0cc5261c79a126b8ad466a39959 to your computer and use it in GitHub Desktop.
PHPでjpgもしくはpngを取得して画像を表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<?php | |
//画像をループするよ(´・ω・`) | |
//ディレクトリ取得 | |
$img_fld = 'image/product/'.$_REQUEST['name']. '/'; | |
//ディレクトリ内の一覧を取得する | |
$img_list = scandir($img_fld); | |
//フォルダ内の画像の数を取得する | |
$count = count($img_fld); | |
//画像を表示させるよ! | |
for($i=0; $i < $count; i++){ | |
$file = pathinfo($img_list[$i]); | |
$file_name = $file["basename"]; | |
$file_ext = $file['extension']; | |
//拡張子がpng,もしくはPNGなら表示、もしdbが取得されたら拒否 | |
if(($file_ext == ('png' or 'PNG' )) and ($file_ext !='db')){ | |
echo '<li>'; | |
echo '<img src="'.$img_fld.$file_name.'">'; | |
echo '</li>'; | |
} | |
} | |
?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment