PHP code example of mikegarde / partition

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

    

mikegarde / partition example snippets




artition\partition;

$data = [
	[
		'id'    => 'A',
		'value' => 5,
	],
	[
		'id'    => 'B',
		'value' => 5,
	],
	[
		'id'    => 'C',
		'value' => 15,
	],
	[
		'id'    => 'D',
		'value' => 5,
	],
	[
		'id'    => 'E',
		'value' => 9,
	],
	[
		'id'    => 'F',
		'value' => 3,
	],
	[
		'id'    => 'G',
		'value' => 7,
	],
	[
		'id'    => 'H',
		'value' => 12,
	],
];

$partition = new partition($data, 4);

$results = $partition->getResults();
$part    = $partition->getPartition(0);
bash
docker build . -t php:7.4

docker run --rm -it -v $(pwd):/var/www/html php:7.4 composer install
docker run --rm -it -v $(pwd):/var/www/html php:7.4 php ./vendor/bin/phpunit --bootstrap vendor/autoload.php tests