PHP code example of xcutionsociety / php-tools

1. Go to this page and download the library: Download xcutionsociety/php-tools 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/ */

    

xcutionsociety / php-tools example snippets


 

use XcS\XcTools;

$rupiah = XcTools::rupiah(5000);

echo $rupiah;
//Rp. 5.000

 
use XcS\XcTools;

class HomeController extends Controller
{
   
    public function __construct()
    {
        /****/
    }

    public function index()
    {
        $rupiah = XcTools::rupiah("5000");
        echo $rupiah;
        //Rp. 5.000
    }

}

 

$data = array(
    array(
        'id' => 1,
        'nama' => "Joni",
        'parent_id' => 0
    ),
    array(
        'id' => 2,
        'nama' => "Joko",
        'parent_id' => 0
    ),
    array(
        'id' => 3,
        'nama' => "Jotte",
        'parent_id' => 0
    ),
    array(
        'id' => 4,
        'nama' => "Doni",
        'parent_id' => 1
    ),
    array(
        'id' => 5,
        'nama' => "Doko",
        'parent_id' => 4
    ),
    array(
        'id' => 6,
        'nama' => "Dotte",
        'parent_id' => 5
    ),
    array(
        'id' => 7,
        'nama' => "Darius",
        'parent_id' => 1
    ),
);

$result = XcTrees::getTreeList($data, $parent = 'parent_id', $son = 'id', $pid = 0, $child = 'childs');
echo json_encode($result);
composer
composer