POP (Parameter Option Parser) can parse options and values from a string
ppm --install="<alias>@github/intellivoid/pop" --branch="production" --fix-conflict
make clean build
sudo make install
$ ./example/bin-cli -h 127.0.0.1 -u=user -p passwd --debug --max-size=3 test
Array
(
[h] => 127.0.0.1
[u] => user
[p] => passwd
[debug] => 1
[max-size] => 3
[test] => 1
)
<?php
/** @noinspection PhpIncludeInspection */
require("ppm");
ppm\ppm::import("net.intellivoid.pop");
$string = '-h 127.0.0.1 -u=user -p passwd --debug --max-size=3 test';
print_r(pop\pop::parse($string));
Output:
Array
(
[h] => 127.0.0.1
[u] => user
[p] => passwd
[debug] => 1
[max-size] => 3
[test] => 1
)