PHP code example of tuvi / easycut

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

    

tuvi / easycut example snippets




use Tuvi\EasyCut;

$easyCut = new EasyCut(['1, 2, 3, 4, 5, 6, 7, 8, 9, 10']);

$subArray = $easyCut->arrayToIndex(4); // [1, 2, 3, 4, 5];

$subArray = $easyCut->arrayToValue(4); // [1, 2, 3, 4];

$subArray = $easyCut->arrayToBeforeIndex(4); // [1, 2, 3, 4];

$subArray = $easyCut->arrayToValue(4); // [1, 2, 3];

$subArray = $easyCut->arrayFromIndex(4); // [5, 6, 7, 8, 9, 10'];

$subArray = $easyCut->arrayFromValue(4); // [4, 5, 6, 7, 8, 9, 10'];

$subArray = $easyCut->arrayAfterIndex(4); // [6, 7, 8, 9, 10'];

$subArray = $easyCut->arrayAfterValue(4); // [5, 6, 7, 8, 9, 10'];



use Tuvi\EasyCut;

$easyDeepCut = new EasyCut([
    [
        'index' => 0,
        'position' => 'one',
        'type' => 'animal',
    ],
    [
        'index' => 1,
        'position' => 'two',
        'type' => 'song',
    ],
    [
        'index' => 2,
        'position' => 'three',
        'type' => 'building',
    ],
    [
        'index' => 3,
        'position' => 'four',
        'type' => 'tool',
    ],
    [
        'index' => 4,
        'position' => 'five',
        'type' => 'spice',
    ]
]);

$easyDeepCut->deepArrayTo('building', 'type');
/* 
[
    [
        'index' => 0,
        'position' => 'one',
        'type' => 'animal',
    ],
    [
        'index' => 1,
        'position' => 'two',
        'type' => 'song',
    ],
    [
        'index' => 2,
        'position' => 'three',
        'type' => 'building',
    ]
];
*/

$easyDeepCut->deepArrayBefore('building', 'type');
/* 
[
    [
        'index' => 0,
        'position' => 'one',
        'type' => 'animal',
    ],
    [
        'index' => 1,
        'position' => 'two',
        'type' => 'song',
    ]
];
*/

$easyDeepCut->deepArrayFrom('building', 'type');
/*
[
    [
        'index' => 2,
        'position' => 'three',
        'type' => 'building',
    ],
    [
        'index' => 3,
        'position' => 'four',
        'type' => 'tool',
    ],
    [
        'index' => 4,
        'position' => 'five',
        'type' => 'spice',
    ]
]
*/

$easyDeepCut->deepArrayAfter('building', 'type');
/*
[
    [
        'index' => 3,
        'position' => 'four',
        'type' => 'tool',
    ],
    [
        'index' => 4,
        'position' => 'five',
        'type' => 'spice',
    ]
]
*/