alphasnow/utils

0.0.1 2022-10-26 01:27 UTC

This package is auto-updated.

Last update: 2024-04-30 00:28:42 UTC


README

Latest Unstable Version Latest Stable Version Total Downloads Tests Coverage Status

Requirement

  • PHP >= 7.2

Install

composer require alphasnow/utils

Example

use AlphaSnow\Utils\ListTree;
$list = [
    ['id' => 1, 'pid' => 0, 'name' => 'node1'],
    ['id' => 2, 'pid' => 1, 'name' => 'node2'],
    ['id' => 3, 'pid' => 2, 'name' => 'node3'],
];
$tree = ListTree::listToTree($list);
/*
[
    ['id' => 1, 'pid' => 0, 'name' => 'node1', '_child' => [
        ['id' => 2, 'pid' => 1, 'name' => 'node2', '_child' => [
            ['id' => 3, 'pid' => 2, 'name' => 'node3']
        ]]
    ]],
];
*/

$name = snake_name('ArticleCategory')
// article_category

Credits

License

MIT License. See the LICENSE file.