将 EXIF 标题添加到 PHP 图库
我现在有以下代码,我想简单地在“CAPTION”文本所在的位置添加 EXIF 标题数据。我该怎么做?我知道如何获取数据,但我不确定如何将其添加到我已经进行的“foreach”循环中。
<?php
$path = "./images/bettydew/";
$file_array = array ();
readThisDir ( $path, &$file_array );
echo '<ul class="gallery">';
foreach ( $file_array as $file )
{
if (strstr($file, "png")||strstr($file, "jpg")||strstr($file, "bmp")||strstr($file, "gif"))
{
echo '<li><a href="javascript:void(0);"><img src="'.$file.'" alt="'.$file.'"/></a></li>';
}
}
echo '</ul>';
function readThisDir ( $path, $arr )
{
if ($handle = opendir($path))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if (is_dir ( $path."/".$file ))
{
readThisDir ($path."/".$file, &$arr);
} else {
$arr[] = $path."/".$file;
}
}
}
closedir($handle);
}
}
?>
I have the following code now, and I want to simply add the EXIF Title data where the "CAPTION" text is. How do I do that? I know how to get the data, but I'm not sure how to add it to the "foreach" loop I already have going.
<?php
$path = "./images/bettydew/";
$file_array = array ();
readThisDir ( $path, &$file_array );
echo '<ul class="gallery">';
foreach ( $file_array as $file )
{
if (strstr($file, "png")||strstr($file, "jpg")||strstr($file, "bmp")||strstr($file, "gif"))
{
echo '<li><a href="javascript:void(0);"><img src="'.$file.'" alt="'.$file.'"/></a></li>';
}
}
echo '</ul>';
function readThisDir ( $path, $arr )
{
if ($handle = opendir($path))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if (is_dir ( $path."/".$file ))
{
readThisDir ($path."/".$file, &$arr);
} else {
$arr[] = $path."/".$file;
}
}
}
closedir($handle);
}
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
foreach
循环替换为:这段代码是我对史蒂夫的其他答案 @Steve - 请再努力一点。
Replace the
foreach
loop with this:this code is my answer to Steve's other SO answer @Steve - Please try harder.