插件28:创建列表

<?php // Plug-in 28: Create List

// This is an executable example with additional code supplied
// To obtain just the plug-ins please click on the Download link

$fruits   = array("Apple", "Pear", "Banana", "Plum", "Orange");
$bullets1 = array("1", "A", "a", "I", "i");
$bullets2 = array("disc", "square", "circle");

echo "<table border='0' width='100%'><tr>";

for ($j = 0 ; $j < 5 ; ++$j)
   echo"<td>" . PIPHP_CreateList($fruits, 1, "ol",
      $bullets1[$j]) . "</td>\n";

echo "</tr><tr>";

for ($j = 0 ; $j < 3 ; ++$j)
   echo"<td>" . PIPHP_CreateList($fruits, 1, "ul",
      $bullets2[$j]) . "</td>\n";

echo "<td colspan='2'></td></tr></table>";

function PIPHP_CreateList($items, $start, $type, $bullet)
{
   // Plug-in 28: Create List
   //
   // This plug-in accepts an array containing a list of
   // items to be displayed in an HTML list, along with some
   // arguments specifying the format, and returns the HTML
   // for the completed list. The arguments requiredare:
   //
   //    $items:  An array containing a list of items
   //    $start:  The start number if displaying ordered list
   //    $type:   The type of list. Either "ol" for ordered,
   //             or "ul" for unordered.
   //    $bullet: The type of bullet. If $type is "ol" the
   //             bullet types can be "1" for numeric, "A"
   //             for upper case alphabetic, "a" for lower
   //             case alphabetic, "I" for upper case Roman,
   //             or "i for lower case Roman numerals. If
   //             $type is "ul" then $bullet can be one of
   //             "disc", "square" or "circle".

   $list = "<$type start='$start' type='$bullet'>";
   foreach ($items as $item) $list .= "<li>$item</li>";
   return $list . "</$type>";
}

?>

插件说明:

本插件需要输入一个数组和列表的格式控制参数。这个数组包含了一个列表的全部列表项,他需要以下参数:

$item 数组,它包含一个列表的全部列表项

$start 有序列表的起始编号

$type 列表的类型,ul表示无序列表,ol表示有序了表。

$bullet 项目符号或列表编号的类型。对于无序列表,有正方形、圆形和圆盘形。

             对于有序列表,又l,A,a,I或i


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值