> For the complete documentation index, see [llms.txt](https://tobyisme.gitbook.io/php/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tobyisme.gitbook.io/php/di-hui.md).

# 遞迴

```php
public function array_diff_assoc_recursive($packetData,$structure){
    $difference = array();
    foreach ($packetData as $k => $v) {
        if (is_array($v)) {
            if (!isset($structure[$k]) || !is_array($structure[$k])) {
                $difference[$k] = $v;
            } else {
                $new_diff = $this->array_diff_assoc_recursive($v, $structure[$k]);
                if (!empty($new_diff)){
                    $difference[$k] = $new_diff;
                }
            }
        } else if (!array_key_exists($k, $structure) /* || $structure[$k] !== $v */) {
            $difference[$k] = $v;
        }
    }
    return $difference;
}
```
