illegal string offset ‘huisnummer’ in if statement

i am trying to fetch information from a json which seemingly worked fine till i ran into this problem: code below, it is giving me the error “Warning: Illegal string offset ‘huisnummer’ in …” and i have no clue why

<?php
class Post extends Controller {
    protected function GetAdresgegevens() {
        $postcode = "7521AG";
        $huisnummer = 437;

        $url = "https://geodata.nationaalgeoregister.nl/locatieserver/free?fq=postcode:$postcode&fq=huisnummer~$huisnummer*";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        $result = json_decode($response, true);
        curl_close($ch); // Close the connection


        $data               = [];
        $data['valid']      = false;
        $data['postcode']   = $postcode;
        $data['woonplaats'] = '';
        $data['huisnummer'] = $huisnummer;
        $data['straatnaam'] = '';

        $docs = $result['response']['docs'];

        if(!empty($docs)) {
            for ($i = 1; $i < count($docs); $i++) {
                foreach ((array) $docs["$i"] as $value) {
                    if ($value["huisnummer"] == $huisnummer && $value['postcode'] == $postcode) {
                        $data['woonplaats'] = $value['woonplaatsnaam'];
                        $data['straatnaam'] = $value['straatnaam'];
                    }
                }
            }
            echo "<pre>";
            print_r($docs);
            echo "</pre>";
            die;
        }

        $this->returnView($data, true, true);
    }
}

if i change it back to $docs[“$i”][“”huisnummer”] it works fine, code:

if(!empty($docs)) {
            for ($i = 1; $i < count($docs); $i++) {
                foreach ((array) $docs["$i"]['huisnummer'] as $value) {
                    if ($value == $huisnummer) {
                        $data['woonplaats'] = $value['woonplaatsnaam'];
                        $data['straatnaam'] = $value['straatnaam'];
                    }
                }
            }
            echo "<pre>";
            print_r($docs);
            echo "</pre>";
            die;
        }