array = ArrayReshape[Range[5 7], {5, 7}];
Fold[ArrayPad, array, {-1, 1}] // MatrixForm // TeXForm
$\left( \begin{array}{ccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 9 & 10 & 11 & 12 & 13 & 0 \\ 0 & 16 & 17 & 18 & 19 & 20 & 0 \\ 0 & 23 & 24 & 25 & 26 & 27 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \end{array} \right)$
Also
ArrayPad[ArrayPad[array, -1], 1] // MatrixForm // TeXForm
ArrayPad[array[[2 ;; -2, 2 ;; -2]], 1] // MatrixForm // TeXForm
array (1 - MorphologicalPerimeter[array]) // MatrixForm // TeXForm
MapAt[0 &, array, {{All, {1, -1}}, {{1, -1}, All}}] // MatrixForm // TeXForm
ReplacePart[array, {1 | Dimensions[array][[1]], _} | {_, 1 | Dimensions[array][[2]]} :> 0]
// MatrixForm // TeXForm
all give the same result.