<div id="gallery">
<?php
$directory = 'people';
$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$ext='';
$title='';
$i=0;
foreach (glob($directory.'/*.{jpg,jpeg,png,gif}', GLOB_BRACE) as $file){
if($file=='.' || $file == '..') continue;
$file_parts = explode('.',$file);
$ext = strtolower(array_pop($file_parts));
$title = basename($file);
$title = htmlspecialchars($title);
echo '
<div class="pic '.$nomargin.'" style="background:url(thumbs/'.$file.') no-repeat 50% 50%;">
<a href="'.$file.'" title="whatever you want : '.$title.'" rel="pan1" target="_blank">'.$title.'</a>
</div>';
$i++;
}
?>
<div class="clear"></div>
</div>
これは、動的画像ギャラリーのコードサンプルです。ディレクトリ内のすべての画像を、別のフォルダのサムネイルとともに自動的に表示します。これが私の問題です。ファイル名に空白の文字または特殊文字を使用すると、ファイルがまったく表示されません。余分なテキストを書かずに画像の説明として画像のタイトルを使用したいので、空白や(ç、ö、ş)などの特殊文字を使用したいと思います。これを行う方法はありますか?ありがとう。