Advertisement
michaelyuen

Untitled

Oct 31st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2. function selected($founders, $id, $name) {
  3. foreach ($founders as $founder) {
  4. // this foreach will create a list of options based on the $founder array
  5. $selected = ($founder == $id) ? ' selected' : '';
  6. // this is to compare the $founder value against $id. If matches, the value would be 'selected' else ''
  7. $options[] = '<option value="'. $founder. '" '. $selected .'>'.$name.'</option>';
  8. // this will push the option html to $options array
  9. }
  10. return implode('', $options);
  11. // this will join the $options array and return the string
  12. }
  13. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement