Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2.  
  3. $handle = fopen("stk.xml", "r") or die("Couldn't get handle");
  4. if ($handle) {
  5. $arr = array();
  6. $previous = "";
  7. while (!feof($handle)) {
  8. $buffer = $previous . fgets($handle, 4096);
  9. while(preg_match("/<record (.*)\/>/",$buffer, $matches)) {
  10. $matches = preg_split("/\" \w/", $matches[1]);
  11. $t = array();
  12. foreach ($matches as $match) {
  13. $match = explode('="', $match);
  14. $t[$match[0]] = $match[1];
  15. }
  16. array_push($arr, $t);
  17. $buffer = preg_replace("/<record (.*)\/>/", "", $buffer, 1);
  18. }
  19. $previous = $buffer;
  20. if(count($arr) > 4) {
  21. file_put_contents("stk.json", json_encode($arr));
  22. file_put_contents("stk_buffer.json", $buffer);
  23. break;
  24. }
  25. }
  26. fclose($handle);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement