Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7998327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:11:14+00:00 2026-06-04T15:11:14+00:00

I am trying to load in all of the images within a folder using

  • 0

I am trying to load in all of the images within a folder using php and then build out a table and pull text from a json file and put it next to each image. The goal is to have json that looks like this.

{
    "Car1": {
        "year":"2012"
    },
    "Car2": {
        "year":"2011"
    },
    "Car3": {
        "year":"2009",
        "milage":"10,204"
    }
}

The Car1, Car2 names will ultimately match the names of the actual images in the folder as well. So i want to grab the image and the correct section in the json file and build out a table listing them all out. So far i have the below php, but am not really sure how to put it all together, as you can see below, its just separate right now. Any suggestions on how to combine the php below to achieve the result i described?


6/1 Edit (New Code using answer below). This is on a page in the spot where i want all of this outputted and the &letter variable is passed from a form on another page. But when that form submits and this page fires off, nothing happens. Am i doing something incorrect?

$letter = $_POST['letter'];

//Call the path of the cars for the chosen letter
$path = "/images/PartsCars/".$letter."/";
$temp_files = scandir($path);

//Call the path for the json file in the chosen letter subfolder
$data = json_decode($string, true);

//Sort the pictures in this folder alphabetically
natsort($temp_files);

echo '<table cellspacing="5" cellpadding="5">';

//Loop through all pictures and json elements to build out the page
foreach($temp_files as $file) 
{
    if($file != "." && $file != ".." && $file != "Thumbs.db" && $file != basename(__FILE__)) 
    {
        echo '<tr>';
        echo '<td><a href="'.$url.$file.'" title="'.$file.'"><img src="'.$url.$file.'" alt="'.$file.'" style="width:300px;height:200px;"/></a></td>';
        $info = pathinfo($file);
        $file_name =  basename($file,'.'.$info['extension']);
        echo '<td>'.print_r($data['$file_name']).'</td>';
        echo '</tr>';
    }
}

echo '</table>';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:11:15+00:00Added an answer on June 4, 2026 at 3:11 pm

    I am using php json_decode for ease of use and using print_r to demo, you could use a foreach loop to print it out properly

    $path = "./images/PartsCars/A/";
    $temp_files = scandir($path);
    $string = file_get_contents("/images/PartsCars/A/sample.json");
    data = json_decode($string, true);
    
    natsort($temp_files);
    
    echo "<table>";
    
    foreach($temp_files as $file) 
    {
        if($file != "." && $file != ".." && $file != "Thumbs.db" && $file != basename(__FILE__)) 
        {
            echo '<tr>';
            echo '<td><a href="'.$url.$file.'" title="'.$file.'"><img src="'.$url.$file.'" alt="" /></a></td>';
            $info = pathinfo($file);
            $file_name =  basename($file,'.'.$info['extension']);
            echo '<td>'.print_r(data['$file_name']).'</td>';
            echo '</tr>'
        }
    }
    echo '</table>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load all images from sdcard's phone on a GridView. I implemented
I'm trying to load image from a plist to a custom cell. It all
I'm trying to load text of all divs that have a particular class into
Afternoon all, Using the code below I'm trying to load what is render by
I am trying to get recursively load all the assets I have placed within
I am trying to create a gridview and load some images from URLs to
I am trying to load images through ajax call in jquery using This here
I was trying to load a few images using java but it seems to
I have a folder of images, altogether 32x32 tiles. I am trying to load
I am trying to load all my Neo4j DB to the RAM so querying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.