<?php
$datasets = array(
// less than 10 entries
array('127.0.0.1'=>45, '10.0.0.9'=>32, '172.16.0.4'=>'16'),
// more than 10 entries
array(
'10.0.0.1'=>45, '10.0.0.2'=>44, '10.0.0.3'=>43, '10.0.0.4'=>42,
'10.0.0.5'=>41, '10.0.0.6'=>40, '10.0.0.7'=>39, '10.0.0.8'=>38,
'10.0.0.9'=>37, '10.0.0.10'=>36, '10.0.0.11'=>35, '10.0.0.12'=>34,
'10.0.0.13'=>33, '10.0.0.14'=>32, '10.0.0.15'=>31, '10.0.0.16'=>30
)
);
foreach ($datasets as $all_ips) {
arsort($all_ips);
$top10 = array_slice($all_ips, 0, 10);
var_export($top10);
echo "\r\n-----\r\n";
}
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- array (
'127.0.0.1' => 45,
'10.0.0.9' => 32,
'172.16.0.4' => '16',
)
-----
array (
'10.0.0.1' => 45,
'10.0.0.2' => 44,
'10.0.0.3' => 43,
'10.0.0.4' => 42,
'10.0.0.5' => 41,
'10.0.0.6' => 40,
'10.0.0.7' => 39,
'10.0.0.8' => 38,
'10.0.0.9' => 37,
'10.0.0.10' => 36,
)
-----
preferences:
176.15 ms | 404 KiB | 198 Q