Breadth-first search. Starting at some cell like (6,4) you mark it as checked* and add it's neighbours to a queue. While the queue is not empty you take the first cell from the front of the queue and check if it's 0. If it is you are done. If not you mark it as checked and add it's unchecked neighbours to the end of the queue. Repeat until you find a 0 or the queue is empty.
* using a second array or the z-axis