public function selectOptions(string $selected = '', array $args = []): string
    {
        $default_args = [
            'ip'     => null,
            'use_ip' => true,
        ];
        $args += $default_args;

        $is_cli = $this->c::isCli();

        if (!isset($args['ip']) && $args['use_ip']) {
            $args['ip'] = $is_cli ? '' : $this->c::currentIp();
        }
        $args['ip']     = (string) $args['ip'];
        $args['use_ip'] = (bool) $args['use_ip'];

        if (!$selected && $args['ip'] && $args['use_ip']) {
            $selected = $is_cli ? '' : $this->c::ipCountry($args['ip']);
        }
        $markup   = ''; // Initialize.
        $selected = mb_strtoupper($selected);

        foreach ($this->ISO3166->getAll() as $_country) {
            $markup .= '<option value="'.$_country['alpha2'].'"'.($selected ? $this->c::selected($selected, $_country['alpha2']) : '').'>'.$_country['name'].'</option>';
        } // unset($_country); // Housekeeping.

        return $markup;
    }
public function selectOptions(string $selected = '', array $args = []): string
    {
        $default_args = [
            'ip'     => null,
            'use_ip' => true,
        ];
        $args += $default_args;

        $is_cli = $this->c::isCli();

        if (!isset($args['ip']) && $args['use_ip']) {
            $args['ip'] = $is_cli ? '' : $this->c::currentIp();
        }
        $args['ip']     = (string) $args['ip'];
        $args['use_ip'] = (bool) $args['use_ip'];

        if (!$selected && $args['ip'] && $args['use_ip']) {
            $selected = $is_cli ? '' : $this->c::ipCountry($args['ip']);
        }
        $markup   = ''; // Initialize.
        $selected = mb_strtoupper($selected);

        foreach ($this->ISO3166->getAll() as $_country) {
            $markup .= '<option value="'.$_country['alpha2'].'"'.($selected ? $this->c::selected($selected, $_country['alpha2']) : '').'>'.$_country['name'].'</option>';
        } // unset($_country); // Housekeeping.

        return $markup;
    }
public function selectOptions ( string $ selected = '' , array $ args = [ ] ) : string { $ default_args = [ 'ip' => null , 'use_ip' => true , ] ; $ args += $ default_args ; $ is_cli = $ this -> c :: isCli ( ) ; if ( ! isset ( $ args [ 'ip' ] ) && $ args [ 'use_ip' ] ) { $ args [ 'ip' ] = $ is_cli ? '' : $ this -> c :: currentIp ( ) ; } $ args [ 'ip' ] = ( string ) $ args [ 'ip' ] ; $ args [ 'use_ip' ] = ( bool ) $ args [ 'use_ip' ] ; if ( ! $ selected && $ args [ 'ip' ] && $ args [ 'use_ip' ] ) { $ selected = $ is_cli ? '' : $ this -> c :: ipCountry ( $ args [ 'ip' ] ) ; } $ markup = '' ; // Initialize. $ selected = mb_strtoupper ( $ selected ) ; foreach ( $ this -> ISO3166 -> getAll ( ) as $ _country ) { $ markup .= '<option value="' . $ _country [ 'alpha2' ] . '"' . ( $ selected ? $ this -> c :: selected ( $ selected , $ _country [ 'alpha2' ] ) : '' ) . '>' . $ _country [ 'name' ] . '</option>' ; } // unset($_country); // Housekeeping. return $ markup ; }
Select menu options.

@since 170329.13807 Country utils.

@param string $selected Selected value.
@param array  $args     Any behavioral args.

@return string HTML markup.
Select menu options .