sorted last login table
This commit is contained in:
@@ -394,16 +394,29 @@ class AppCard
|
||||
*/
|
||||
function lastLoginTable($jsonFileName = 'lastLogins.json')
|
||||
{
|
||||
// load the jsonfile into an associative array
|
||||
$lastLogins = json_decode(file_get_contents($jsonFileName), true);
|
||||
|
||||
// collecting the last login of the users ...
|
||||
$lastLoginRows = [];
|
||||
foreach ($lastLogins as $userName => $lastLogins) {
|
||||
$lastLoginRows[$userName] = $lastLogins['lastLogins'][0];
|
||||
}
|
||||
// and sort it so the last login is first in line
|
||||
arsort($lastLoginRows);
|
||||
|
||||
// build the table
|
||||
$lastLoginsTable =
|
||||
'<table>' .
|
||||
'<thead><tr><th>userName</th><th>lastLogins</th></tr></thead>' .
|
||||
'<thead><tr><th>userName</th><th>lastLogin</th></tr></thead>' .
|
||||
'<tbody>';
|
||||
foreach ($lastLogins as $userName => $lastLogins) {
|
||||
foreach ($lastLoginRows as $userName => $lastLogin) {
|
||||
$lastLoginsTable .=
|
||||
'<tr><td>' . $userName . '</td><td>' . $lastLogins['lastLogins'][0] . '</td></tr>';
|
||||
'<tr><td>' . $userName . '</td><td>' . $lastLogin . '</td></tr>';
|
||||
}
|
||||
$lastLoginsTable .= '</tbody></table>';
|
||||
$lastLoginsTable .=
|
||||
'</tbody>'.
|
||||
'</table>';
|
||||
return $lastLoginsTable;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user