Guest User

Untitled

a guest
Jan 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. //The actual config file:
  2.  
  3. define host{
  4. use wireless-client
  5. host_name Joe-Hammer
  6. alias Joe Hammer
  7. address 10.0.0.13
  8. }
  9.  
  10.  
  11. ################################
  12.  
  13. // the pertinent code where $s is a single line from fgets()
  14. ...
  15.  
  16. $v=preg_split("/[\s,]+/", $s); // What do I put in here to survive the space in the alias?
  17.  
  18. if(isset($v[0]) && isset($v[1])){
  19. $var=ltrim(rtrim($v[0]));
  20. $val=ltrim(rtrim($v[1]));
  21. }
  22.  
  23. $contents[$datatype][$current_host][$var]=$val;
  24.  
  25. ....
  26.  
  27. ################################
  28.  
  29. // The [desired] result
  30.  
  31. [0] => Array
  32. (
  33. [use] => wireless-client
  34. [host_name] => Joe-Hammer
  35. [alias] => Joe Hammer
  36. [address] => 10.0.0.13
  37. )
  38.  
  39. // 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