Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $pilih = "Female";
- $array = ["Laki Laki", "Perempuan", "Humu", "RIyan", "Female", "Male"];
- function select($array,$selected)
- {
- echo '<select>';
- foreach($array as $val)
- {
- if($val == $selected)
- {
- $dipilih = 'selected';
- }
- else
- {
- $dipilih = '';
- }
- echo "<option value='{$val}' $dipilih> {$val} </option>";
- }
- echo '</select>';
- }
- //tampilkan
- select($array, $pilih); //select(array,selected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement