title: Json data Group by value using php
body: <p>I want to display team ranking be based on pool group. </p>
  
  <p>Here is my Json Data  </p>
  
  <pre><code>    {"rows":[{"team":{"id":172725,"pool":1},"stats":[{"name":"played","value":1},{"name":"won","value":1},{"name":"lost","value":0},{"name":"points","value":"2.0"},{"name":"net_run_rate","value":"+6.325"}],"rank":"1"},
  {"team":{"id":172726,"pool":3},"stats":[{"name":"played","value":0},{"name":"won","value":0},{"name":"lost","value":0},{"name":"points","value":"0.0"},{"name":"net_run_rate","value":"+0.000"}],"rank":"*"},
  {"team":{"id":172727,"pool":2},"stats":[{"name":"played","value":1},{"name":"won","value":1},{"name":"lost","value":0},{"name":"points","value":"1.0"},{"name":"net_run_rate","value":"+4.455"}],"rank":"1"},
  {"team":{"id":172728,"pool":1},"stats":[{"name":"played","value":1},{"name":"won","value":0},{"name":"lost","value":1},{"name":"points","value":"0.0"},{"name":"net_run_rate","value":"-6.325"}],"rank":"2"},
  {"team":{"id":172729,"pool":2},"stats":[{"name":"played","value":1},{"name":"won","value":0},{"name":"lost","value":1},{"name":"points","value":"0.0"},{"name":"net_run_rate","value":"-4.455"}],"rank":"2"}]}
  </code></pre>
  
  <p>Current php to code to output is :</p>
  
  <pre><code>foreach ($read_json-&gt;rows as $item) {               
  $id = empty($item-&gt;team-&gt;id) ? "" : $item-&gt;team-&gt;id;                
  $pool  = empty($item-&gt;team-&gt;pool) ? "" : $item-&gt;team-&gt;pool;
  $rank = empty($item-&gt;rank) ? "" : $item-&gt;rank;  
  $played = empty($item-&gt;stats[0]-&gt;value) ? "0" : $item-&gt;stats[0]-&gt;value;
  $won = empty($item-&gt;stats[1]-&gt;value) ? "0" : $item-&gt;stats[1]-&gt;value;
  $lost = empty($item-&gt;stats[2]-&gt;value) ? "0" : $item-&gt;stats[2]-&gt;value;               
  $points = empty($item-&gt;stats[9]-&gt;value) ? "0" : $item-&gt;stats[9]-&gt;value;
  $net_run_rate= empty($item-&gt;stats[12]-&gt;value) ? "0" : $item-&gt;stats[12]-&gt;value;                      
  echo "&lt;div&gt;$id&lt;/div&gt;&lt;div&gt;$rank&lt;/div&gt;&lt;div&gt;$played&lt;/div&gt;&lt;div&gt;$won&lt;/div&gt;&lt;div&gt;$lost&lt;/div&gt;&lt;div&gt;$points&lt;/div&gt;&lt;div&gt;$net_run_rate&lt;/div&gt;\n";
  echo " &lt;/div&gt;\n";
  }
  </code></pre>
  
  <p>I want to group it as per the pool number. Please see the result here:</p>
  
  <p><a href="https://i.stack.imgur.com/yQk3O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yQk3O.png" alt="enter image description here"></a></p>