PHP code example of artnv / tree-builder

1. Go to this page and download the library: Download artnv/tree-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

artnv / tree-builder example snippets


$tb = TreeBuilder::create($dataArr, null, null, false);
// create($inputArr, $aliases = null, $userParams = [], $sort_enabled = true);

$dataArr[] = [
    'id' => 1
    'parent_id' => 0
    'img' => '123.jpg'
    'name' => 'Category #1'
    'keywords' => ''
    'description' => ''
    'position' => 2
];

$aliases = [
    'id' => 'id',
    'parent' => 'parent',
    'title' => 'title',
    'child' => 'child',
    'position' => 'position',
];

$userParams = [];

$sort_enabled = true;

childNode($item, $childNodes, $aliases, $nestingLevel, $userParams);

rootNode($nodes, $firstStart, $userParams);

$node_1 = ['parent' => 24];
$node_2 = ['id' => 888];

php v0.2
js  v0.1.1