I 이미지 갤러리를 위해 다음과 같은 코드가 있습니다논리 AND 연산자 && foreach는 PHP에서 사용
$directory = 'some path';
$thumbs_directory = 'some path';
foreach (glob($directory.'/*.{jpg,jpeg,png,gif}', GLOB_BRACE) as $file)
foreach (glob($thumbs_directory.'/*.{jpg,jpeg,png,gif}', GLOB_BRACE) as $file2)
{
if($file=='.' || $file == '..') continue;
$file_parts = explode('.',$file);
$ext = strtolower(array_pop($file_parts));
$title = basename($file);
$title = htmlspecialchars($title);
$title = str_replace("_"," ",$title);
$nomargin='';
if(($i+1)%4==0) $nomargin='nomargin';
echo '
<div class="pic '.$nomargin.'" style="background:url('.$file2.') no-repeat 50% 50%;">
<a href="'.$file.'" title="'.$title.'" target="_blank">'.$title.'</a>
</div>';
$i++;
}
내가 논리 AND 연산자를 통해 이들의 foreach 문을 결합해야을 & & 그래서 두 조건이 모두에 만족하는지 같은 시간. 가능한가? 여러 번 시도했지만 구문 오류가 발생합니다.
$ file 및 $ file2 변수를 완벽하게 정의해야합니다. 이는 미리보기 이미지가 이미지와 적절하게 연결되는 유일한 방법입니다.
어떤 조건입니까? – Blender
당신은'array_merge()를 찾고 있습니다. – mario
저는 두 파일 사이에서 유지하려고하는 실제 관계가 아니라 "논리적 AND"에 대한 반복적 인 언급이 여기에 있습니다. – IMSoP