Skip to content

Instantly share code, notes, and snippets.

@LegendZhu
Last active December 18, 2015 05:48
Show Gist options
  • Save LegendZhu/5735015 to your computer and use it in GitHub Desktop.
Save LegendZhu/5735015 to your computer and use it in GitHub Desktop.
通过PREVIEW_TOTLE、ROW_NUMBER参数控制页面的显示【总数表示标签不足时共显示多少格子】 元素少于配置时的总数空格补位和超过时的补位
<?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>&nbsp;</td>";
}
if($last < 0 && abs($last) % $row > 0){
for($k = 0;$k < ROW_NUMBER - abs($last) % $row; $k++){
echo "<td>&nbsp;</td>";
}
}
$j = 0;
?>
@LegendZhu
Copy link
Author

alt text

@LegendZhu
Copy link
Author

alt text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment