Given a 2D matrix, your task is to print all its elements in a spiral order starting from the top-left corner and moving clockwise layer by layer.
In spiral order, you start by printing the top row, then the rightmost column, then the bottom row in reverse, and finally the leftmost column from bottom to top. This process is repeated for the inner layers until all elements are printed.
If the matrix is empty or has no elements, the output should be an empty list.