gpt4 book ai didi

php - 如何通过PHP中的关联数组将两个值传递给一个变量

转载 作者:搜寻专家 更新时间:2023-10-31 21:30:27 25 4
gpt4 key购买 nike

我有一个来自 UberGallery 的 UberGallery.php这是我正在使用的。

对于每个图像弹出窗口,图像底部显示图像名称(例如 4488826 6f061c99ec b d),该图像取自 UberGallery.php

  // Loop through array and add additional info
foreach ($dirArray as $key => $image) {
// Get files relative path
$relativePath = $this->_rImgDir . '/' . $key;

$galleryArray['images'][htmlentities(pathinfo($image['real_path'], PATHINFO_BASENAME))] = array(
'file_title' => str_replace('_', ' ', pathinfo($image['real_path'], PATHINFO_FILENAME)),
'file_path' => htmlentities($relativePath),
'thumb_path' => $this->_createThumbnail($image['real_path'])
);
}
上面代码中的

file_title 正在影响要更改的标题。图像在 defaultGallery.php 中显示如下

 <?php if (!empty($images) && $stats['total_images'] > 0): ?>

<ul id="galleryList" class="clearfix">

<?php foreach ($images as $image): ?>
<li><a href="<?php echo html_entity_decode($image['file_path']); ?>" title="<?php echo $image['file_title']; ?>" rel="<?php echo $relText; ?>"><img src="<?php echo $image['thumb_path']; ?>" alt="<?php echo $image['file_title']; ?>"/></a></li>
<?php endforeach; ?>

</ul>

<?php else: ?>

<p>No images found.</p>

<?php endif; ?>

现在我想在每个图片弹出窗口的图片底部显示图片名称 (4488826 6f061c99ec b d) 和电子邮件地址 (aaa@gmail.com)。

如果我在上面的 file_title 的 str_replace 函数中更改为从 csv 文件获取电子邮件地址,那么什么也不会出现。gallery.csv 有两个字段,例如 4488826 6f061c99ec b d aaa@gmail.com。我想将这两个值传递给 file_title,以便它们出现在图像弹出窗口中。

$file_handle = fopen("gallery.csv", "r");

while (!feof($file_handle)) {

$lines_of_text[] = fgetcsv($file_handle, 1024);
}
fclose($file_handle);

// Loop through array and add additional info
foreach ($dirArray as $key => $image) {
// Get files relative path
$relativePath = $this->_rImgDir . '/' . $key;

$galleryArray['images'][htmlentities(pathinfo($image['real_path'], PATHINFO_BASENAME))] = array(
'file_title' => str_replace('_', $lines_of_text[1], pathinfo($image['real_path'], PATHINFO_FILENAME)),
'file_path' => htmlentities($relativePath),
'thumb_path' => $this->_createThumbnail($image['real_path'])
);
}

我应该如何将姓名和电子邮件传递给上面的 file_title 以获得所需的结果?还是有其他方法可以做到这一点?

请帮我找出解决办法。

最佳答案

像这样试试这个

 $galleryArray['images'][htmlentities(pathinfo($image['real_path'], PATHINFO_BASENAME))] = array(
'file_title' => ' ',
'file_path' => htmlentities($relativePath),
'thumb_path' => $this->_createThumbnail($image['real_path'])
);

关于php - 如何通过PHP中的关联数组将两个值传递给一个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30572039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com