g3x0

Untitled

Sep 5th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. $cont = file_get_contents('catz.txt');
  4. $cont = explode("\n", $cont);
  5. $cats = array();
  6.  
  7. foreach ($cont as $line)
  8. {
  9.     $temp = explode(":", $line);
  10.     $maincat = $temp[0];
  11.  
  12.     $temp2 = explode(" => ", $temp[1]);
  13.     $subcat = $temp2[0];
  14.     $catid = $temp2[1];
  15.  
  16.     $cats[$maincat] = array();
  17. }
  18.  
  19. foreach ($cont as $line)
  20. {
  21.     $temp = explode(":", $line);
  22.     $maincat = $temp[0];
  23.  
  24.     $temp2 = explode(" => ", $temp[1]);
  25.     $subcat = $temp2[0];
  26.     $catid = $temp2[1];
  27.  
  28.     $cats[$maincat][$subcat] = $catid;
  29. }
  30.  
  31. print_r($cats);
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment