title: How to get the data from a collection array in Laravel
body: <p>I have this Collection Array in <code>Laravel</code> that is from the database
  <a href="https://i.stack.imgur.com/tahcM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tahcM.png" alt="enter image description here"></a></p>
  
  <pre><code> public function getdiagnosistally(){
  
        $jsonData = ListBuilder::all()-&gt;pluck('listdata');
          $res = $jsonData-&gt;contains('Test');
          dd($jsonData,$res);
  }
  </code></pre>
  
  <p>I was wondering if it is possible to count the occurrences of the following data inside the collection.</p>
  
  <p>I have tried using below contain method but it does not give me a true result even if there is Test inside the Collection.</p>
  
  <pre><code> $res = $jsonData-&gt;contains('Test');
  </code></pre>
  
  <p>I have also tried using count method but it only gives me the total amount of the collection not the count of Test which is 2 but the result gives me 6.</p>
  
  <pre><code> $res = $jsonData-&gt;count('Test');
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/vQtnR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vQtnR.png" alt="enter image description here"></a></p>
  
  <p>The end result i was aiming is like it will be counting the occurrences of Test from the json data.</p>
  
  <p>for example :-</p>
  
  <pre><code>Test = 2
  Test child 1 = 4
  </code></pre>
  
  <p>Would you be able to advice how i can fix it?</p>