如何在数组中添加 PHP 分页
2022-08-30 22:33:26
我一直在尝试很多方法来添加PHP分页。我尝试过搜索并尝试找出实现分页的其他方法,但没有一种有效。
以下是我创建索引页的方式:
<?php
$menuItems = array(
"post1" => array(
"title" => "Sample Title",
"utime" => "M/d/Y",
"content" => "<p>Body of the post</p>"
),
"post2" => array(
"title" => "Another Sample Title",
"utime" => "M/d/Y",
"content" => "<p>Content goes here...</p>"
),
);
foreach ($menuItems as $contItem => $item) {
?>
<li>
<a href="dish.php?item=<?php echo $contItem; ?>">
<h1><?php echo $item["title"]; ?></h1>
<small><?php echo $item["utime"]; ?></small>
</a>
</li>
<?php } ?>
我想知道如何对数组列表进行分页。谢谢!