title: Php array count total value from key value pair
body: <p>this is my array output:</p>
  
  <pre><code>array:2 [
    0 =&gt; array:1 [
      "medium " =&gt; " 1"
    ]
    1 =&gt; array:1 [
      " small " =&gt; " 2"
    ]
  ]
  </code></pre>
  
  <p>My solution</p>
  
  <pre><code>$sumVariant = array();
              foreach ($data as $key =&gt; $value) {
                          foreach ($value as $k =&gt; $v) {
                                      //dd(trim($v));
                              $sumVariant += trim($v);
                          }
              }
  dd($sumVariant);
  </code></pre>
  
  <p>How can I count total for both <code>medium</code> and <code>small</code> which return 3? Thanks!!</p>