Jump to content

[SOLVED] Need to create drop down box with data pulled from text file


mazman13

Recommended Posts

Trying to make a drop down box like this example:

 

Dog

Cat

Bird

 

But sometimes I will need to update it...and add/remove names from the list. I want to do it fast and easy and I don't want to use a MySQL Database. I'd rather use a text file...can that be done?

 

I would keep the info in a text file and then push it to a drop down box via php and html.

Let me know if this will work.

 

Yes it will work.

 

Code would be something like this:

$text = file_get_contents("test.txt");
$array = explode("\n",$text);
echo "<select>";
foreach ($array as $value) {
echo "<option value='$value'>$value</option>";
}
echo "</select>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.