Since array indexes only have a certain level of specificity (i.e. you can only subdivide down to the width, in this case 32), there's no one perfect way to represent a sphere in an array. Instead, we can treat each array index as a space of cubic area, where the [x][y][z] indices of the index represent the the cubic area's center coordinates. To create the sphere, we evaluate whether the sphere's presence in that area of space meets certain criteria.
We start with the equation for a sphere. From Wikipedia:
In analytic geometry, a sphere with center (x0, y0, z0) and radius r is the locus of all points (x, y, z) such that
(x - x0)^2 + (y - y0)^2 + (z - z0)^2 <= r^2.
For an array of dimensions N, the center will have the coordinate (N - 1) / 2 for all dimensions. (because for an even-numbered dimension, the center should be between the two center points, and for an odd-numbered dimension, the center should be an integer.) The magnitude of the radius can vary depending on where you decide the boundaries of the sphere relative to our imagined cubic array representation; re-reading the question, I notice you already gave the desired radius: 4.
There are two evaluation criteria I can think of:
Simple approach
In this approach, we will simply use a test of whether the array index's cubic area's center lies within the circle equation.
You can see Siddharth Satpathy's answer for some code using this approach.
Sophisticated approach
Ideally for me, the equation would decide whether an index lies within the sphere by assessing whether the proportion of sphere for that cubic area is greater than 50%. However, this approach unfortunately goes beyond my current working mathematical knowledge.
In regards to a discussion I had in the comments, neither approach is better than the other since they represent different perspectives: I personally imagine the array as being actually representative of the cubic area for each index, while others may imagine the indexes being the center points of these cubic areas.