PHP array and select list

后端 未结 4 1144
一整个雨季
一整个雨季 2020-12-16 20:47

I want to use php array for HTML select list. In this case it will be the list of countries but beside of country name that is listed in drop down list I need as a value of

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 21:07

    Use foreach(), it's the best function to loop through arrays

    your array should look like jakenoble posted

    
    

    I also made some minor adjustements to your html code. The first option in the list will be selected by default so no need to specify it ;)

    EDIT: I made some edits after reading your question again

提交回复
热议问题