1. Go to this page and download the library: Download stefangabos/zebra_mptt 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/ */
stefangabos / zebra_mptt example snippets
// include the Zebra_Mptt class
// (you don't need this if you are using Composer)
add 'Food' as a topmost node
$food = $mptt->add(0, 'Food');
// 'Fruit' and 'Meat' are direct descendants of 'Food'
$fruit = $mptt->add($food, 'Fruit');
$meat = $mptt->add($food, 'Meat');
// 'Red' and 'Yellow' are direct descendants of 'Fruit'
$red = $mptt->add($fruit, 'Red');
$yellow = $mptt->add($fruit, 'Yellow');
// add a fruit of each color
$cherry = $mptt->add($red, 'Cherry');
$banana = $mptt->add($yellow, 'Banana');
// add two kinds of meat
$mptt->add($meat, 'Beef');
$mptt->add($meat, 'Pork');
// move 'Banana' to 'Meat'
$mptt->move($banana, $meat);
// get a flat array of descendants of 'Meat'
$mptt->get_descendants($meat);
// get a multidimensional array (a tree) of all the data in the database
$mptt->get_tree();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.