How to Populate Dropdown List with Array Values in PHP? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report We will create an array, and then populate the array elements to the dropdown list in PHP. It is a common task when you want to provide users with a selection of options. There are three approaches to achieve this, including using a foreach loop, array_map() function, and implode() function. Here, we will explore each approach with detailed explanations and code examples. Table of Content Using foreach LoopUsing array_map() FunctionUsing implode() FunctionApproach 1: Populate Dropdown List with Array Values using foreach LoopYou can use a foreach loop to iterate over an array of elements and populate the dropdown list with its values. PHP <?php $options = array( "HTML", "CSS", "JavaScript", "PHP" ); ?> <select> <?php foreach ($options as $option): ?> <option value="<?php echo $option; ?>"> <?php echo $option; ?> </option> <?php endforeach; ?> </select> Output: Approach 2: Populate Dropdown List with Array Values using array_map() FunctionThe array_map() function can be used to apply a callback function to each element of an array. You can use it to generate the <option> tags for the dropdown list. PHP <?php $options = array( "HTML", "CSS", "JavaScript", "PHP" ); ?> <select> <?php echo implode(array_map(function($option) { return "<option value=\"$option\">$option</option>"; }, $options)); ?> </select> Output: Approach 3: Populate Dropdown List with Array Values using implode() FunctionYou can also use the implode() function to concatenate the array values into a string and then use it to populate the dropdown list. PHP <?php $options = array( "HTML", "CSS", "JavaScript", "PHP" ); ?> <select> <?php echo "<option>" . implode("</option><option>", $options) . "</option>"; ?> </select> Output: Create Quiz Comment B blalverma92 Follow 0 Improve B blalverma92 Follow 0 Improve Article Tags : PHP PHP-Questions Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like