In PHP, how do I paginate arrays with strong typing?

PHP pagination, strong typing, PHP arrays
This example demonstrates how to paginate arrays in PHP using strong typing for better data handling.
<?php declare(strict_types=1); function paginateArray(array $data, int $page, int $itemsPerPage): array { $offset = ($page - 1) * $itemsPerPage; return array_slice($data, $offset, $itemsPerPage); } // Example array to paginate $data = range(1, 100); // an array with numbers 1-100 $page = 2; // current page number $itemsPerPage = 10; // items to display per page $paginatedData = paginateArray($data, $page, $itemsPerPage); print_r($paginatedData); ?>

PHP pagination strong typing PHP arrays