Counting values in array
<p>I am trying to get values from this array and counting them. Let's say we have Amsterdam and I would like to count value [41, 21, 43] together and put them in a html table. The problem is that the values sometimes miss as you can see below. How can I achieve this?</p>

<pre><code>Array
(
    [Amsterdam] =&gt; Array
        (
            [41] =&gt; 2
            [21] =&gt; 91
            [43] =&gt; 16
            [42] =&gt; 2
            [20] =&gt; 30
            [4] =&gt; 4
            [70] =&gt; 3
            [84] =&gt; 8
            [46] =&gt; 4
            [45] =&gt; 5
            [999] =&gt; 26
            [47] =&gt; 2
            [3] =&gt; 8
            [44] =&gt; 1
            [40] =&gt; 1
            [93] =&gt; 5
            [56] =&gt; 3
            [61] =&gt; 3
            [79] =&gt; 3
            [48] =&gt; 2
            [50] =&gt; 5
            [10] =&gt; 10
            [52] =&gt; 2
            [120] =&gt; 1
            [95] =&gt; 1
            [1] =&gt; 64
            [90] =&gt; 4
            [100] =&gt; 2
            [101] =&gt; 1
        )

    [Rotterdam] =&gt; Array
        (
            [21] =&gt; 42
            [41] =&gt; 2
            [42] =&gt; 2
            [46] =&gt; 1
            [47] =&gt; 2
            [43] =&gt; 4
            [45] =&gt; 3
            [4] =&gt; 1
            [3] =&gt; 19
            [84] =&gt; 1
            [12] =&gt; 1
            [20] =&gt; 14
            [40] =&gt; 1
            [48] =&gt; 6
            [61] =&gt; 1
            [52] =&gt; 1
            [10] =&gt; 4
            [1] =&gt; 23
            [90] =&gt; 2
        )

    [Spaarnwoude] =&gt; Array
        (
            [21] =&gt; 2
        )
</code></pre>

<p>This is what I already tried:</p>

<pre><code>  foreach ($headings as $h) {
        echo "&lt;th&gt;$h&lt;/th&gt;";
    }
    echo '&lt;/tr&gt;';

    foreach($cities as $cityname =&gt; $city) { 
        echo '&lt;tr&gt;';
        echo "&lt;td&gt;$cityname&lt;/td&gt;";
        foreach (array_chunk($headings, 3) as $h) {
            echo '&lt;td&gt;' . (isset($city[$h]) ? $city[$h] : '0') . '&lt;/td&gt;';
        }    
        echo '&lt;/tr&gt;';
    }

    echo '&lt;/table&gt;';
</code></pre>

<p>For further information you can check this link.</p>

<p><a href="https://stackoverflow.com/questions/34675118/how-to-get-array-output-in-html-table">How to get array output in html table</a></p>