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 4030446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:28:22+00:00 2026-05-20T11:28:22+00:00

I wanted to ask how can I populate an HTML list with Images located

  • 0

I wanted to ask how can I populate an HTML list with Images located in a folder automatically?

lets say I have 4 pages with 4 different lists.
lets say the lists are as follows: Cars, Motorcycles, Airplanes, Ships
each list entry has a src as a thumbnail and a href as a link to full size image.
my folder contain images with specific titles:
C=Cars
M=Motorcycles
A=Airplanes
S=Ships

then I have a serial number

and the ending is either
T=Thumbnail
F=Full Image

so a complete file name would be C20T.jpg or C20F.jpg.

I am looking for a script that will update the 4 lists according to their subject and populate them automatically with related file names.

from my search here I have found this piece of code but I believe it needs some tweaking and I am not sure how to do this 🙁

$dir    = '/images';
$files = scandir($dir);
$images = array();
foreach($files as $file) {
  if(fnmatch('*.jpg',$file)) {
    $images[] = $file;
  }
}

foreach($images as $image) {
  echo '<img src="images/'.$image.'" />';
}

I hope someone could help me with this!

Thank you for your time reading this.

  • 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-05-20T11:28:23+00:00Added an answer on May 20, 2026 at 11:28 am
    $type = 'c';
    
    $imagesDir = 'images/';
    
    $images = glob($imagesDir . $type . '*[TYPE].{jpg,jpeg,png,gif}', GLOB_BRACE);
    

    This should get all your full images.

    Making a ul is then pretty easy…

    <ul>
    <?php foreach($images as $image): ?>
       <li><a href="<?php echo str_replace('[TYPE]', 'F', $image); ?>"><img src="<?php echo str_replace('[TYPE]', 'T', $image); ?></a>" alt="" /></li>
    <?php endforeach; ?>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still new to the API and I wanted to ask: Can you send
I have a block of code that works and I wanted to ask what
Hey guys I wanted to ask if you can do some conditional checks on
I just wanted to ask if we can access an external MySQL server from
I wanted to ask Stack Overflow users for a nice idea for a project
We are having some performance issues with a page and I wanted to ask
I am curious to learn Boost . But I wanted to ask: How important
I know this is somewhat of a server question, but I wanted to ask
After reading an article about the subject from O'Reilly , I wanted to ask
Wanted to convert <br/> <br/> <br/> <br/> <br/> into <br/>

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.