LoginSignup
3
1

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);
3
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
3
1