Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $arr = [];
- $depths = [];
- $ids = [];
- function my_comparator($a, $b)
- {
- {
- return ( (0 + $a['LEFT_MARGIN']) - ( 0 +$b['LEFT_MARGIN']));
- }
- }
- function my_decoder($file_path)
- {
- $i = -1;
- if ($file = fopen($file_path, "r")) { //создание потока из файла на чтение
- while(!feof($file))
- {
- $line = fgets($file);
- if (substr_count($line, "Array"))
- {
- $i++;
- continue;
- }
- elseif (substr_count($line, '(') or substr_count($line, ')'))
- {
- continue;
- }
- //elseif (substr_count($line, "LEFT_MARGIN")) {
- $searcharr = ['>', '[', ']', ' ', '\r', '\n'];
- $line = trim($line = str_replace($searcharr, '', $line));
- global $arr;
- parse_str($line, $arr[$i][]);
- // }
- }
- global $arr;
- for($i = 0; $i < count($arr); $i++)
- {
- for($k = $i + 1; $k < count($arr); $k++)
- {
- if ($arr[$i][8]['LEFT_MARGIN'] > $arr[$k][8]['LEFT_MARGIN'])
- {
- $var = $arr[$k];
- $arr[$k] = $arr[$i];
- $arr[$i] = $var;
- }
- }
- }
- fclose($file);
- }
- }
- $temp = "C:\Users\ykouc\Downloads\array.txt";
- my_decoder($temp);
- global $arr;
- for ($i = 0; $i < count($arr);$i++)
- {
- for ($j = 1; $j < (int)$arr[$i][6]['DEPTH_LEVEL'];$j++)
- {
- printf(" ");
- }
- printf("%s \n", $arr[$i][4]['NAME']);
- }
- echo 1;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement