I want to access ‘residentsInfo’ structure field ‘countries’ so i can count how many different countries there are (without counting same country twice).
Firstly i can’t even access my field inside a structure…
In the future, please don’t post screenshots of code, but code blocks to work with.
You have to loop through your residents variable, only then can you access the fields of each individual item. See the structure field documentation in the reference.
I get an error Call to a member function count() on string
And this:
<?= $countries->count() ?>
Throws me Call to a member function count() on array
What i want is instead of displaying “usa lt en” countries it should return number 3, because there is such quantity of different countries inside an archive. What am I doing wrong…?