src/Utils.php
public static function getopts($options)
    {
        $opts = getopt(implode('', array_keys($options)), $options);

        $result = array();
        foreach ($options as $short => $long) {
            $short = trim($short, ':');
            $long = trim($long, ':');

            if (isset($opts[$short])) {
                $result[$long] = $opts[$short];
            } elseif (isset($opts[$long])) {
                $result[$long] = $opts[$long];
            }
        }

        return $result;
    }
public static function getopts($options)
    {
        $opts = getopt(implode('', array_keys($options)), $options);

        $result = array();
        foreach ($options as $short => $long) {
            $short = trim($short, ':');
            $long = trim($long, ':');

            if (isset($opts[$short])) {
                $result[$long] = $opts[$short];
            } elseif (isset($opts[$long])) {
                $result[$long] = $opts[$long];
            }
        }

        return $result;
    }
public static function getopts ( $ options ) { $ opts = getopt ( implode ( '' , array_keys ( $ options ) ) , $ options ) ; $ result = array ( ) ; foreach ( $ options as $ short => $ long ) { $ short = trim ( $ short , ':' ) ; $ long = trim ( $ long , ':' ) ; if ( isset ( $ opts [ $ short ] ) ) { $ result [ $ long ] = $ opts [ $ short ] ; } elseif ( isset ( $ opts [ $ long ] ) ) { $ result [ $ long ] = $ opts [ $ long ] ; } } return $ result ; }
`getopts` is very convenient, but annoying how one has to check for both
the long & short versions for values; this will always return an array
with the long opt as key, even if the user passed it as short.

@param array $options [short => long]

@return array
getopts is very convenient but annoying how one has to check for both the long & short versions for values ; this will always return an array with the long opt as key even if the user passed it as short .