If you extend this script to also support an array of possible container sizes, and then finding the combination that fits all boxes, it would be even more perfect :)
Example:
$container_sizes = array(
array(
'length' => 10,
'height' => 5,
'width' => 25
),
array(
'length' => 15,
'height' => 15,
'width' => 40
)
);
$boxes = array(); // Boxes with dimensions
$packer = new LAFFPacker();
$packer->pack($boxes, $container_sizes);
$containers = $packer->get_containers(); // Array of containers
If you extend this script to also support an array of possible container sizes, and then finding the combination that fits all boxes, it would be even more perfect :)
Example: