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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:41:05+00:00 2026-05-21T14:41:05+00:00

I have $data which contains something like this and changes often: backup 2011-04-15 16:39:18.559965.zip

  • 0

I have $data which contains something like this and changes often:

backup 2011-04-15 16:39:18.559965.zip
backup 2011-04-15 16:39:56.289656.zip
backup 2011-04-15 16:41:34.463754.zip
backup 2011-04-15 16:41:54.089134.zip
backup 2011-04-15 16:42:18.742616.zip
backup 2011-04-16 13:12:33.083622.zip
backup 2011-04-16 13:14:53.387308.zip
backup 2011-04-17 00:30:32.591461.zip

How can i make that it will transform it into a Dropdown list, so people can choose from and i can use result as $_POST[‘file’]?

  • 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-21T14:41:06+00:00Added an answer on May 21, 2026 at 2:41 pm
    1. Read text using fopen()
    2. Split text into array using explode()
    3. Loopt trough array using foreach()
    4. echo elements between option tags.

    EDIT

    I did not provide any code because you should be able to write this yourself following the steps above. Simply use Google to find out how these functions work. You can only learn PHP by implementing things yourself. Don’t expect people to write complete scripts for you.

    Anyways, this should be working 🙂

    $path = "files.txt";
    $file = fopen($path, 'r');
    $data = fread($file, filesize($path));
    fclose($file);
    
    $lines =  explode(PHP_EOL,$data);
    echo '<select name="file">';
    foreach($lines as $line) {
      echo '<option value="'. urlencode($line).'">'.$line.'</option>';
    }
    echo '</select>';
    

    You can also use file_get_contents() instead of fopen().

    $data = file_get_contents("files.txt");
    

    EDIT

    Added file() like recommended by Wiseguy

    $lines = file('files.txt');
    echo '<select name="file">';
    foreach($lines as $line) {
      echo '<option value="'. urlencode($line).'">'.$line.'</option>';
    }
    echo '</select>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a core data 'ShoppingList' which contains 'Item' objects. I store a display
I have a row of data which contains numbers and splits by '-', sth
Let's assume that we have a data frame x which contains the columns job
I have a table which contains data about which node has been visited. It
I have a text file which contains data seperated by '|'. I need to
I have a txt file which contains data in the following format: X1 Y1
I have a huge data.table in R which contains the result of a experiment:
I have a stack which contains some integer data. I want to find out
I have a database which contains picture data stored as a binary blob. The
I have a string which contains binary data ( non-text data ). How do

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.