Last active
December 18, 2015 05:48
-
-
Save LegendZhu/5735015 to your computer and use it in GitHub Desktop.
通过PREVIEW_TOTLE、ROW_NUMBER参数控制页面的显示【总数表示标签不足时共显示多少格子】
元素少于配置时的总数空格补位和超过时的补位
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('PREVIEW_TOTLE', 15);//总数 | |
define('ROW_NUMBER', 3);//每行的个数,应可被TOTLE整除 | |
$total = PREVIEW_TOTLE; | |
$row = ROW_NUMBER; | |
$count = count($val['tag_ids']); | |
$last = $total - $count; | |
$j = 0; | |
foreach($val['tag_ids'] as $k => $v){ | |
if($j % $row == 0 && $j != 0){ | |
echo "</tr><tr>"; | |
} | |
$j++; | |
echo "<td>$v</td>"; | |
} | |
for($i = 0;$i < $last; $i++){ | |
if($j % $row == 0 && $j != 0){ | |
echo "<tr/><tr>"; | |
} | |
$j++; | |
echo "<td> </td>"; | |
} | |
if($last < 0 && abs($last) % $row > 0){ | |
for($k = 0;$k < ROW_NUMBER - abs($last) % $row; $k++){ | |
echo "<td> </td>"; | |
} | |
} | |
$j = 0; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment