Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php populate select from array

$array = array(
  1=>"My first option",
  2=> "My second option"
);

<select>
  <?php foreach($array as $key => $value) { ?>
    <option value="<?php echo $key ?>"><?php echo $value ?></option>
  <?php }?>
</select>
Comment

PREVIOUS NEXT
Code Example
Php :: Only Show Specific Countries In Caldera Forms Phone Field 
Php :: call node js jquery http php 
Php :: php double dollar not working in php version 8 
Php :: laravel task scheduler error 
Php :: hardening PHP7 
Php :: display PHP errors based on environment variable 
Php :: php remove new line character from string 
Php :: Same Taxonomy Add Multiple Post Type 
Php :: twig global 
Php :: laravel download file from AWS s3 
Php :: afiseaza id-ul sesiunii php 
Php :: omnipay refund 
Php :: how return cutomize error text the firstOrFail laravel exeption 
Php :: Random select value on array factory Laravel 
Php :: php artisan tinker new record 
Php :: Laravel retrieving aggregates 
Php :: describe request php-salesforce-rest-api 
Php :: Debloat Wordpress 
Php :: code snippet for header footer in wordpress 
Php :: int to string in php 
Php :: laravel get polymorphic names 
Php :: PHP Validate POST value emoty & Set 
Php :: Registering a variable with $_SESSION. 
Php :: automatically create html page using php and mysql 
Php :: check input value is not empty or spaced php 
Php :: import export csv file in laravel 
Php :: quiz 
Php :: yajra add column 
Php :: laravel framework 
Php :: laravel model bind with route in model 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =