Implementation of BinPacking (2D) in PHP