getopt

PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
getopt - Gets options from the command line argument list
Manual
Code Examples

Example #1 getopt example: The basics

Result: array(2) { ["f"]=> string(5) "value" ["h"]=> bool(false) }
PHP Version:

Example #2 getopt example: Introducing long options

Result: array(6) { ["f"]=> string(11) "value for f" ["v"]=> bool(false) ["a"]=> bool(false) ["required"]=> string(5) "value" ["optional"]=> string(14) "optional value" ["option"]=> bool(false) }
PHP Version:

Example #3 getopt example: Passing multiple options as one

Result: array(2) { ["a"]=> array(3) { [0]=> bool(false) [1]=> bool(false) [2]=> bool(false) } ["c"]=> bool(false) }
PHP Version:

Example #4 getopt example: Using <span class='function-parameter'>rest_index</span>

Result: array(1) { [0]=> string(4) "test" }
PHP Version: