Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function selected($founders, $id, $name) {
- foreach ($founders as $founder) {
- // this foreach will create a list of options based on the $founder array
- $selected = ($founder == $id) ? ' selected' : '';
- // this is to compare the $founder value against $id. If matches, the value would be 'selected' else ''
- $options[] = '<option value="'. $founder. '" '. $selected .'>'.$name.'</option>';
- // this will push the option html to $options array
- }
- return implode('', $options);
- // this will join the $options array and return the string
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement