Jump to content

[SOLVED] Building a select box from an array


Bricktop

Recommended Posts

Hi all,

 

I have an array and some code to build a select box from that array, however I keep getting:

 

Warning: Invalid argument supplied for foreach() in NAMEOFFILE.php on line XXX

 

My code is as follows:

 

$domaintypes = array(
".com" =>".com",
".co.uk" =>".co.uk",
".net" =>".net",
".org" =>".org"
);


$content .='<select name="tld">';

foreach($domaintypes as $key => $value){
$content .= '<option value="'.$key.'">'.$value.'</option>';
}

$content .='</select>';
echo $content;

 

Any ideas where I've gone wrong?

 

Thanks

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.