public function dropdownItems(string $active = '', array $args = []): string
    {
        $default_args = [
            'ip'     => null,
            'use_ip' => true,
            'flags'  => false,
        ];
        $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'];
        $args['flags']  = (bool) $args['flags'];

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

        foreach ($this->ISO3166->getAll() as $_country) {
            $_alpha2_lc = mb_strtolower($_country['alpha2']);
            $_flag      = $args['flags'] ? '<i class="'.$_alpha2_lc.' flag"></i>' : '';
            $markup .= '<div class="item'.($active ? $this->c::activeSelected($active, $_country['alpha2']) : '').'" data-value="'.$_country['alpha2'].'">'.$_flag.$_country['name'].'</div>';
        } // unset($_country, $_alpha2_lc, $_flag); // Housekeeping.

        return $markup;
    }
public function dropdownItems(string $active = '', array $args = []): string
    {
        $default_args = [
            'ip'     => null,
            'use_ip' => true,
            'flags'  => false,
        ];
        $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'];
        $args['flags']  = (bool) $args['flags'];

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

        foreach ($this->ISO3166->getAll() as $_country) {
            $_alpha2_lc = mb_strtolower($_country['alpha2']);
            $_flag      = $args['flags'] ? '<i class="'.$_alpha2_lc.' flag"></i>' : '';
            $markup .= '<div class="item'.($active ? $this->c::activeSelected($active, $_country['alpha2']) : '').'" data-value="'.$_country['alpha2'].'">'.$_flag.$_country['name'].'</div>';
        } // unset($_country, $_alpha2_lc, $_flag); // Housekeeping.

        return $markup;
    }
public function dropdownItems ( string $ active = '' , array $ args = [ ] ) : string { $ default_args = [ 'ip' => null , 'use_ip' => true , 'flags' => false , ] ; $ 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' ] ; $ args [ 'flags' ] = ( bool ) $ args [ 'flags' ] ; if ( ! $ active && $ args [ 'ip' ] && $ args [ 'use_ip' ] ) { $ active = $ is_cli ? '' : $ this -> c :: ipCountry ( $ args [ 'ip' ] ) ; } $ markup = '' ; // Initialize. $ active = mb_strtoupper ( $ active ) ; foreach ( $ this -> ISO3166 -> getAll ( ) as $ _country ) { $ _alpha2_lc = mb_strtolower ( $ _country [ 'alpha2' ] ) ; $ _flag = $ args [ 'flags' ] ? '<i class="' . $ _alpha2_lc . ' flag"></i>' : '' ; $ markup .= '<div class="item' . ( $ active ? $ this -> c :: activeSelected ( $ active , $ _country [ 'alpha2' ] ) : '' ) . '" data-value="' . $ _country [ 'alpha2' ] . '">' . $ _flag . $ _country [ 'name' ] . '</div>' ; } // unset($_country, $_alpha2_lc, $_flag); // Housekeeping. return $ markup ; }
Dropdown menu items.

@since 170329.13807 Country utils.

@param string $active Active value.
@param array  $args   Any behavioral args.

@return string HTML markup.
Dropdown menu items .