<?php
$pageNumber = 1;
$pageHeight = 7;
$commands = [
"foo" => ["name" => "foo", "desc" => "Foo Desc", "perm" => true],
"fuu" => ["name" => "fuu", "desc" => "Fuu Desc", "perm" => false],
"bar" => ["name" => "bar", "desc" => "Foo Desc", "perm" => true],
];
ksort($commands, SORT_NATURAL | SORT_FLAG_CASE);
$commands = array_chunk($commands, $pageHeight);
$pageNumber = (int) min(count($commands), $pageNumber);
printf("PageNumber=%d, CountCommands=%d", $pageNumber, count($commands));
foreach($commands[$pageNumber - 1] as $command){
printf("Name=%s, Desc=%s", $command["name"], $command["desc"]);
}
- Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 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.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- PageNumber=1, CountCommands=1Name=bar, Desc=Foo DescName=foo, Desc=Foo DescName=fuu, Desc=Fuu Desc
preferences:
202.47 ms | 403 KiB | 284 Q