I need to process a variable through some validation to return a value of which I can use later on in my script. My $var is coming from a GET.
Example: A variable may come through like below.
$var = 'main server app1 stop'
I need to break up the string as follows.
main server needs to look up a list like below and return the ip address.
192.168.10.1 = 'main server'
192.168.10.2 = 'backup server'
app1 also needs to be looked up in a list and return the match.
service httpd = 'app1'
service iptables = 'app2'
Then bring back the relevant matches together. In this example I would want the following returned.
192.168.10.1 service httpd stop
I hope I have explained this clear enough. If not tell me what I need to detail more.
Thanks!
explode(php.net/manual/en/function.explode.php) to convert a string to an array - it's simpler to irritate an array than a string in my opinion.