I'm working on an open source chat software, and it's time I rewrite my commands; I've got this idea I'd like to get accomplished but I'm having a hard time getting it done.
I want my commands do look something like this: (any of you that have linux experience should get what I'm trying to accomplish)
/example -custom="Custom User" -time=65 This is an example message
now, a more real world example would be:
/ban -time=15 Bad_User Stop Flooding
As you can see, I am going for the linux cmd line goal, this is easy but I am struggling with trying to get the values inside the quotes. This is the code I have so far.
Code: Select all
$cmd = "-duration=55 -perm=yes -rofl=5 -nice=\"this is a tesT\" JeFFb68CAM test message";
preg_match_all("/-(.*?)=(\w+|\".*\")/", $cmd, $matches);
echo "<pre>";
print_r($matches);Code: Select all
Array
(
[0] => Array
(
[0] => -duration=55
[1] => -perm=yes
[2] => -rofl=5
[3] => -nice="this is a tesT"
)
[1] => Array
(
[0] => duration
[1] => perm
[2] => rofl
[3] => nice
)
[2] => Array
(
[0] => 55
[1] => yes
[2] => 5
[3] => "this is a tesT"
)
)Any help is appreciated, thanks;
Jeff