<?php

function printTree( array $tree , string $key =  , string $stack =  , $first = TRUE , $firstPadding = NULL )
{
    if ( gettype($tree) ==  )
    {
        if($firstPadding === NULL) $firstPadding = ( count($tree)>1 )?  :  ;
        echo   $key . PHP_EOL ;
        foreach ($tree as $key => $value) {
            if ($key === array_key_last($tree)){
                echo (($first)?  : $firstPadding ) . $stack . ;
                $padding = ;
                if($first) $firstPadding = ;
            }
            else {
                echo (($first)?  : $firstPadding ) . $stack . ;
                $padding = ;
            }
            if( is_array($value) )printTree( $value , $key ,   $stack . (($first)?  : $padding ) , FALSE , $firstPadding );
            else echo $key .  . $value . PHP_EOL;
        }
    }
    else echo $tree . PHP_EOL;
}






$sample_array_1 = 
[
    0 => [
        'item_id' => 6,
        'price' => ,
        'qty' => 12,
        'discount' => 0
    ],
    1 => [
        'item_id' => 7,
        'price' => ,
        'qty' => 1,
        'discount' => 12
    ],
    2 => [
        'item_id' => 8,
        'price' => ,
        'qty' => 0,
        'discount' => 24
    ]
];
$sample_array_2 = array(
    array(
         =>,
        =>,
        =>,
        =>,
        =>,
        =>array(
                =>,
                =>array(
                        =>
                )
        )

    )
);
$sample_array_3 = [
     => [
         =>[
            ,
             => [
                 ,
                 ,
                 => [
                    ,
                    ,
                ]
                ],
            ,
        ] ,
         => [
             => [  => [1]]
        ]
        ]
];
$sample_array_4 = [];
$sample_array_5 = [];
$sample_array_5 = [];
$sample_array_6 = [
    ,
    ,
    ,
    ,
    ,
    ,
    ,
    ,
    ,
    ,
    ,
];


printTree($sample_array_1);
echo PHP_EOL .  . PHP_EOL;
printTree($sample_array_2);
echo PHP_EOL .  . PHP_EOL;
printTree($sample_array_3);
echo PHP_EOL .  . PHP_EOL;
printTree($sample_array_4);
echo PHP_EOL .  . PHP_EOL;
printTree($sample_array_5);
echo PHP_EOL .  . PHP_EOL;
printTree($sample_array_6);


?>