0

Here i need advice from you guys.

Name/username              Host                                    Dyn Forcerport ACL Port     Status     Realtime
6000/6000                  (Unspecified)                             D   N      16207    Unmonitored
6001/6001                  192.168.1.101                           D   N      0        Unmonitored
6003/6003                  (Unspecified)                            D   N      0        Unmonitored
6005/6005                  (Unspecified)                            D   N      0        Unmonitored
4 sip peers [Monitored: 0 online, 0 offline Unmonitored: 1 online, 3 offline]

I am getting above information in a string format. The IP address in host column shows that 6001 user is online. But if want get only username and its address or Unspecified keyword into an array.
1) How how could i get it using regex or string functions in PHP? 2) username column may vary, for example if 6003 user is deleted then your provided technique might not work.

Thanks a lot...!

hakre
  • 178,314
  • 47
  • 389
  • 754

1 Answers1

3

I would not use a regular expression for that:

  • Explode the string by newlines so you have an array containing all lines
  • Explode each line by spaces / tabs / ... so you have each entry
jeroen
  • 88,615
  • 21
  • 107
  • 128