Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //The actual config file:
- define host{
- use wireless-client
- host_name Joe-Hammer
- alias Joe Hammer
- address 10.0.0.13
- }
- ################################
- // the pertinent code where $s is a single line from fgets()
- ...
- $v=preg_split("/[\s,]+/", $s); // What do I put in here to survive the space in the alias?
- if(isset($v[0]) && isset($v[1])){
- $var=ltrim(rtrim($v[0]));
- $val=ltrim(rtrim($v[1]));
- }
- $contents[$datatype][$current_host][$var]=$val;
- ....
- ################################
- // The [desired] result
- [0] => Array
- (
- [use] => wireless-client
- [host_name] => Joe-Hammer
- [alias] => Joe Hammer
- [address] => 10.0.0.13
- )
- // So far, I get it all except the space in the alias kills things and drops the last name.
Add Comment
Please, Sign In to add comment