Bricktop Posted August 3, 2009 Share Posted August 3, 2009 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 Link to comment https://forums.phpfreaks.com/topic/168661-solved-building-a-select-box-from-an-array/ Share on other sites More sharing options...
Daniel0 Posted August 3, 2009 Share Posted August 3, 2009 My code is as follows: No it isn't. That code cannot result in that error. Link to comment https://forums.phpfreaks.com/topic/168661-solved-building-a-select-box-from-an-array/#findComment-889731 Share on other sites More sharing options...
Bricktop Posted August 3, 2009 Author Share Posted August 3, 2009 You're correct, it's working now. When I pasted the code here I did delete a couple of unneeded " marks, I that's obviously what was causing the problem. Many thanks! Link to comment https://forums.phpfreaks.com/topic/168661-solved-building-a-select-box-from-an-array/#findComment-889735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.