I want to display team ranking be based on pool group.
Here is my Json Data
{"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"}]}
Current php to code to output is :
foreach ($read_json->rows as $item) {
$id = empty($item->team->id) ? "" : $item->team->id;
$pool = empty($item->team->pool) ? "" : $item->team->pool;
$rank = empty($item->rank) ? "" : $item->rank;
$played = empty($item->stats[0]->value) ? "0" : $item->stats[0]->value;
$won = empty($item->stats[1]->value) ? "0" : $item->stats[1]->value;
$lost = empty($item->stats[2]->value) ? "0" : $item->stats[2]->value;
$points = empty($item->stats[9]->value) ? "0" : $item->stats[9]->value;
$net_run_rate= empty($item->stats[12]->value) ? "0" : $item->stats[12]->value;
echo "<div>$id</div><div>$rank</div><div>$played</div><div>$won</div><div>$lost</div><div>$points</div><div>$net_run_rate</div>\n";
echo " </div>\n";
}
I want to group it as per the pool number. Please see the result here: