DFS | 93.33% Beats | 3ms | PHP
Code

# Code
```php []
class Solution {

    /**
     * @param Integer[][] $isConnected
     * @return Integer
     */
    function findCircleNum($isConnected) {
        $n = count($isConnected);
        $visited = array_fill(0, $n, false); // To keep track of visited cities
        $provinces = 0;

        // Iterate through all cities
        for ($i = 0; $i < $n; $i++) {
            if (!$visited[$i]) {
                $provinces++; // Found a new province
                $this->dfs($i, $visited, $isConnected, $n);
            }
        }

        return $provinces;
    }

    // Depth-First Search (DFS) helper function
    private function dfs($node, &$visited, $isConnected, $n) {
        $visited[$node] = true;

        for ($neighbor = 0; $neighbor < $n; $neighbor++) {
            if ($isConnected[$node][$neighbor] == 1 && !$visited[$neighbor]) {
                $this->dfs($neighbor, $visited, $isConnected, $n);
            }
        }
    }
}
```
['PHP']