I'm working in PHP and trying to parse the information that I get from a configuration file on disk. The line looks like this:
option ssh '-p 443 -i /root/.ssh/id_rsa -N -T -R 0.0.0.0:2222:localhost:22 [email protected]
I've tried with regex or with using awk|cut under php's exec but I'm not having any success.
My ideal return value looks something like this:
return $this->response = array(
"host" => "example.com",
"port" => "443",
"user" => "root",
"lport" => "22",
"rport" => "2222"
);
How do I get the arguments I need from the string with RegEx?
preg_splitgetoptas it looks like you're parsing command line input