How to find the shortest side of the box in php?