fork download
  1. <?php
  2. $string = "
  3. CLIENT_LIST orion-01889596000195 177.43.212.110:28763 172.16.191.145 872199 860412 Wed May 25 07:22:52 2016 1464171772 UNDEF
  4. CLIENT_LIST elgin-05997632000195 189.10.58.244:62588 172.16.6.210 301365 250459 Wed May 25 07:01:37 2016 1464170497 UNDEF
  5. CLIENT_LIST databits-13031005000123 187.17.235.203:50515 172.16.136.217 459833 409771 Wed May 25 06:09:01 2016 1464167341 UNDEF
  6. CLIENT_LIST UNDEF 201.14.8.164:1134 42 54 Wed May 25 15:05:07 2016 1464199507 UNDEF
  7. CLIENT_LIST elgin-15259334000151 187.5.4.138:56256 172.16.19.10 172756 170025 Wed May 25 08:26:39 2016 1464175599 UNDEF
  8.  
  9. ";
  10.  
  11. function processador($str){
  12. $partes = preg_split("/\t/", trim($str));
  13. $data = array_slice($partes, 1);
  14. return array_map("filtro", $data);
  15. }
  16. function filtro($str){
  17. return str_replace("UNDEF", "", $str);
  18. }
  19.  
  20. $linhas = array_filter(explode("\n", $string));
  21. $resultado = array_map("processador", $linhas);
  22.  
  23. echo var_dump($resultado);
  24.  
  25.  
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
array(5) {
  [1]=>
  array(8) {
    [0]=>
    string(20) "orion-01889596000195"
    [1]=>
    string(20) "177.43.212.110:28763"
    [2]=>
    string(14) "172.16.191.145"
    [3]=>
    string(6) "872199"
    [4]=>
    string(6) "860412"
    [5]=>
    string(24) "Wed May 25 07:22:52 2016"
    [6]=>
    string(10) "1464171772"
    [7]=>
    string(0) ""
  }
  [2]=>
  array(8) {
    [0]=>
    string(20) "elgin-05997632000195"
    [1]=>
    string(19) "189.10.58.244:62588"
    [2]=>
    string(12) "172.16.6.210"
    [3]=>
    string(6) "301365"
    [4]=>
    string(6) "250459"
    [5]=>
    string(24) "Wed May 25 07:01:37 2016"
    [6]=>
    string(10) "1464170497"
    [7]=>
    string(0) ""
  }
  [3]=>
  array(8) {
    [0]=>
    string(23) "databits-13031005000123"
    [1]=>
    string(20) "187.17.235.203:50515"
    [2]=>
    string(14) "172.16.136.217"
    [3]=>
    string(6) "459833"
    [4]=>
    string(6) "409771"
    [5]=>
    string(24) "Wed May 25 06:09:01 2016"
    [6]=>
    string(10) "1464167341"
    [7]=>
    string(0) ""
  }
  [4]=>
  array(8) {
    [0]=>
    string(0) ""
    [1]=>
    string(17) "201.14.8.164:1134"
    [2]=>
    string(0) ""
    [3]=>
    string(2) "42"
    [4]=>
    string(2) "54"
    [5]=>
    string(24) "Wed May 25 15:05:07 2016"
    [6]=>
    string(10) "1464199507"
    [7]=>
    string(0) ""
  }
  [5]=>
  array(8) {
    [0]=>
    string(20) "elgin-15259334000151"
    [1]=>
    string(17) "187.5.4.138:56256"
    [2]=>
    string(12) "172.16.19.10"
    [3]=>
    string(6) "172756"
    [4]=>
    string(6) "170025"
    [5]=>
    string(24) "Wed May 25 08:26:39 2016"
    [6]=>
    string(10) "1464175599"
    [7]=>
    string(0) ""
  }
}