Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2.  
  3. function parseShittyFile($string) {
  4.  
  5.     // daca functia va primi un STRING si nu un FISIER, comenteaza linia de mai jos
  6.     $string = file_get_contents($string);
  7.  
  8.     preg_match_all('#-A (\w+)#', $string, $a);
  9.     preg_match_all('#-j (\w+)#', $string, $j);
  10.  
  11.     foreach (array_unique($j[1]) as $j_parameter) {
  12.        
  13.         if (!in_array($j_parameter, array_unique($a[1]))) {
  14.             $string = str_replace("-j $j_parameter", "-j " . strtoupper($j_parameter), $string);
  15.         }
  16.        
  17.     }
  18.  
  19.     return $string;
  20.    
  21. }
  22. // mod de folosire (a se servi calda):
  23. echo parseShittyFile("string_file.txt");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement