Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function show_states_select()
- {
- global $current_user;
- $states = array(
- array(
- 'abbr' => 'AR',
- 'fullname' => 'Arkansas'
- ),
- array(
- 'abbr' => 'TX',
- 'fullname' => 'Texas'
- )
- );
- $select = "<select name=\"my-states\">\n%s</select>\n";
- $format = "<option value=\"%s\"%s>%s</option>\n";
- $opts = '';
- for($i=0; $i<count($states); $i++)
- {
- $opts .= sprintf($format, $states[$i]['abbr'], selected($states[$i]['abbr'], $current_user->State),
- $states[$i]['fullname']);
- }
- printf($select, $opts);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement