私のルートフォルダに複数の画像があります/images/filename.here
。画像ファイル名は次のとおりです(電子メール):[email protected]
、[email protected]_1.jpg
、[email protected]_2.jpg
、[email protected]
画像ファイル名が存在するかどうかを確認する
存在する場合、ユーザーの1つの画像のみを示す上の私のコード[email protected]
と[email protected]
:
<?
$email= $data['payment']['email'];
$receipts = "images/".$email;
if (file_exists($receipts)) { ?>
<img src="<?=($receipts)?>" width:"100px" height="50px"/>
<? } else {
echo "no receipt";
} ?>
これだけ「なし_x
」ファイル名を表示します。ループ_1
、_2
、_3
...を使用して、ユーザーの他の画像(me @ yahooなど)を表示するにはどうすればいいですか?ユーザーに属するすべての画像が表示されるはずです。
場合、カウンターでwhileループを作成します。カウンタが0の場合、$ filename = $ email(0以上の場合)、$ filename = $ email。 "_"。$ counter。ファイル名が存在しない場合は、whileを終了します。 – theatlasroom