我将图像文件信息推送到数组中。 这很简单,除了关键字有时也是一个数组。 这对我现在正在做的事很好。 这里是我的阵列php数组关键字计数器
$list[]=array(filename=>$file,width=>$w,height=>$h,caption=>$iptc["2#120"],keywords=>$iptc["2#025"]);
我可以用这个阵列来输出所需的幻灯片的JavaScript的HTML的一个样本。
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
//if this file is a valid image
$path = $dirname . "" . $file ;
$path2 = $dirname ."JPEG/" . $file ;
$size = getimagesize($path, $info);
$w = $size[0]; $h = $size[1];
$iptc = iptcparse($info['APP13']);
if(in_array($key,$iptc["2#025"])){
$list[]=array(
filename=>$file,
width=>$w,
height=>$h,
caption=>$iptc["2#120"],
keywords=>$iptc["2#025"]
);
}
}
}
closedir($handle); }
我希望能够在数组中添加另一个变量,因为每个唯一的关键字都会被添加。这将允许我直接进入幻灯片显示的中间,因为我使用的js幻灯片只有直接链接,如果引用了一个数字
我想我需要创建一个唯一的所有关键字数组然后有一些类型的复杂的if语句为每个唯一变量的数.....
,但是我不知道如何做到这一点
帮助请
感谢
杰里米
是一个循环内的代码? – dbf
这里是完整的代码(是的代码是在一个循环中) – user1690012
如果($处理=执行opendir($目录名)){ \t而(假的!==($文件= READDIR($处理))){ \t \t if(eregi($ pattern,$ file)){//如果此文件是有效图像 \t $ path = $ dirname。 “”。 $ file; $ path2 = $ dirname。“JPEG /”。 $ file; $ size = getimagesize($ path,$ info); $ w = $ size [0]; $ h = $ size [1]; $ iptc = iptcparse($ info ['APP13']); \t if(in_array($ key,$ iptc [“2#025”])){ \t $ list [] = array(filename => $ file,width => $ w,height => $ h,caption = > $ IPTC [ “2#120”],关键字=> $ IPTC [ “2#025”]); } } } \t closedir($ handle); } – user1690012