Skip to content

Instantly share code, notes, and snippets.

@pjaudiomv
Last active January 6, 2019 15:01
Show Gist options
  • Save pjaudiomv/5b23bd30e9a22fda4a367d3c934a887d to your computer and use it in GitHub Desktop.
Save pjaudiomv/5b23bd30e9a22fda4a367d3c934a887d to your computer and use it in GitHub Desktop.
Get and count top 20 meeting names in tomato
<?php
$tomatoEndpoint = 'https://tomato.na-bmlt.org/main_server/client_interface/json/?switcher=GetSearchResults&data_field_key=meeting_name';
$meetingNames = json_decode(file_get_contents($tomatoEndpoint), true);
$meetings = array();
foreach ($meetingNames as $key => $value) {
// do a tiny bit of cleanup
$meetings[] = str_replace(' GROUP', '', trim(strtoupper($value['meeting_name'])));
}
$meetings = array_count_values($meetings); // Count Values
asort($meetings); // Sort
$meetings = array_slice($meetings,-20,20,true); // Get only last 20
$meetings = array_reverse($meetings, true); // Reverse so highest values start first
//print_r($meetings);
$i = 0;
foreach ($meetings as $key => $value) {
$i++;
echo $i . '. ' . $key . ' ' . $value . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment