It is necessary to visualize the house with apartments. Suppose there is a 3-storey house and three entrances, it has 27 apartments
As a result, get something like this 
There is an array of data, you need to bring it to the form, as in the picture (approximately)
$ array = ['number' => 1, 'floor' => 3, 'enters' => 3, 'rooms' => 27];
With HTML + CSS no problem. The problem is how to properly assemble an array for output.
Yes, here is the usual mathematics: 27 apartments / 3 entrances We get 9 apartments in the 1st entrance 9 apartments / 3 floors We get 3 apartments on the floor
But how to make the generation in the 1st entrance in the following order 7,8,9 - 4,5,6 - 1,2,3, I can not think of