I would like to replicate a matrix like this:

A matrix with straight horizontal and vertical lines forming a rectangle around its content.
I tried using array environment with hlines
$$
\begin{array}{c|cccccccc|}
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\
\hline
a & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
b & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
c & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
d & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
e & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\hline
\end{array}
$$
but got this intead:

Is it possible to do it in latex or do i need an external program to generate such picture and insert it?




\cline{2-9, i.e. without the closing brace. – Torbjørn T. May 08 '16 at 11:43\shorthandoff{-}in a useful place, see edited answer. – Torbjørn T. May 08 '16 at 11:52\clineandbabel-czech– egreg May 08 '16 at 12:37