<?php require_once 'ResultTree.php'; require_once 'mockresults.php'; // Get the mock result. $result = getResult(); // Create our tree... $tree = new ResultTree($result); // Print out the tree. print_r($tree->getTree()); // Print out the tree with a filter. print_r($tree->getTree(4)); // Now print out the flat results. print_r($tree->getFlat(0, TRUE)); // Now print out the flat results filtered. print_r($tree->getFlat(4, TRUE));
// Add this id to our array. $ids[] = $id; // Add that result to the items. $flat[] = $this->result[$value->index]; // If this has a child, then. if ($value->children) { // Normalize the children. $this->_getFlat($value, $flat); } } } } } } $url = 'http://www.akkord-tour.com.ua/get-xml.php?get_category=true'; $categories = simplexml_load_file($url); $categories_array = getCategoriesArray($categories); function getCategoriesArray($categories) { $categories_array = array(); foreach ($categories->children() as $category) { $categories_array["{$category->category_id}"] = array(); $categories_array["{$category->category_id}"]['id'] = $category->category_parent_id * 1; $categories_array["{$category->category_id}"]['pid'] = $category->category_parent_id * 1; $categories_array["{$category->category_id}"]['Title'] = "{$category->category_name}"; } return $categories_array; } //var_dump($categories_array); $tree = new ResultTree($categories_array); var_dump($tree->getTree());