Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $handle = fopen("stk.xml", "r") or die("Couldn't get handle");
- if ($handle) {
- $arr = array();
- $previous = "";
- while (!feof($handle)) {
- $buffer = $previous . fgets($handle, 4096);
- while(preg_match("/<record (.*)\/>/",$buffer, $matches)) {
- $matches = preg_split("/\" \w/", $matches[1]);
- $t = array();
- foreach ($matches as $match) {
- $match = explode('="', $match);
- $t[$match[0]] = $match[1];
- }
- array_push($arr, $t);
- $buffer = preg_replace("/<record (.*)\/>/", "", $buffer, 1);
- }
- $previous = $buffer;
- if(count($arr) > 4) {
- file_put_contents("stk.json", json_encode($arr));
- file_put_contents("stk_buffer.json", $buffer);
- break;
- }
- }
- fclose($handle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement