Right now, I have the code below that makes this
However, I'd like to do two things. One, change the indices to be on over the boxes instead of under. Two, add more rows so that this is a 2D array, hopefully with different amount of spacing in between the rows and columns.
Basically, I want this but where every row is different.

Any help is appreciated!
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcounter{index}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\setcounter{index}{0}
\coordinate (s) at (0,0);
\foreach \num in {3, 1, 4, 1, 5}{
\node[minimum size=6mm, draw, rectangle] at (s) {\num};
\node at ($(s)-(0,0.5)$) {\theindex};
\stepcounter{index}
\coordinate (s) at ($(s) + (1,0)$);
}
\end{tikzpicture}
\label{fig:testArray}
\end{figure}
\end{document}



