How to pass two values ​​in one variable through an associative array in PHP

I have UberGallery.php from UberGallery that I am using.

For each image popup, there is an image name (e.g. 4488826 6f061c99ec bd) displayed at the bottom of the image, which is taken from 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 from the previous code affects this title, which needs to be changed. Images are displayed as below, by default: Gallery.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; ?>

      

Now I want to show the image name (4488826 6f061c99ec bd) and email address ( aaa@gmail.com ) as below the image for each popup image.

if i change above file_title str_replace

function to get email address from csv file nothing appears. gallery.csv

has two fields of type 4488826 6f061c99ec b d aaa@gmail.com

. These are the two values ​​that I want to pass to file_title so that they appear in the popup.

$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'])
                );
            }

      

How can I pass the name and email address above file_title to get the desired result? Or is there any other way to do this?

Please help me find a solution.

+3


source to share


1 answer


try this for example



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

      

+1


source







All Articles