4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPでデータ数から最大ページ数を計算する

Last updated at Posted at 2015-09-18

び、備忘録……

なんとかして$countに総データ数を入れさえすればこれでOKなハズ。
この場合、$dataが配列な想定で……

ソース

<?php
// 1ページで表示したいデータ数
$i = 30;
// データの個数を入れる
$count = count($data);
// データ個数 ÷ 1ページに表示するデータ数 (端数の切り上げ)
$max_page = ceil($count / $i); 

// 結果表示
var_dump($max_page);
4
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?