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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:16:01+00:00 2026-06-08T18:16:01+00:00

I have an array of images being displayed from a specific directory using the

  • 0

I have an array of images being displayed from a specific directory using the following code:

<?php 
    $dir = "img";
    $files = scandir($dir); 
    echo '<pre>', htmlspecialchars(print_r($files, true)), "</pre>\n";  
?>

The output of this code is as follows:

Array
(
    [0] => .
    [1] => ..
    [2] => image_1.png
    [3] => image_2.png
    [4] => image_3.png
)

What I would like to do is display the array of images as shown below thus removing [x] => for each image and also removing Array ( ).

image_1.png
image_2.png
image_3.png

Im not sure how to go about this. I have never really worked with arrays before therefore the only methods I can think of are preg_replace() or str_replace(), but honestly not sure where I would start.

Any help would be kindly appreciated.

  • 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-08T18:16:02+00:00Added an answer on June 8, 2026 at 6:16 pm

    Try:

    echo '<pre>', htmlspecialchars(join("\n", $files)), "</pre>\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using PHP and I have an array of user images that I
I am using jQuery to build an array of images from a php array.
I have an array of urls of images, from which i have to first
I need to get array of images that have to call from server and
i have an associative array in PHP. $myarray = array( a=>News, b=>Articles, c=>images );
UPDATE 2: I have now removed the following from the .php file: <?php error_reporting(
I'm using altered sample code from PhotoScroller within my app. I have a table
I have a servlet based application that is serving images from files stored locally.
I have a function that retrieves some images from a JSON feed using NSURLConnection.
I am trying to select existing images from a directory. The image files are

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.