Makes creating ordered, unordered, definition and custom html lists as easy as drawing a circle on a piece of paper.
| Lister | |
| ordered | ( $list [, $enclose ] ) |
| unordered | ( $list [, $enclose ] ) |
| definition | ( $list ) |
| custom | ( $delimit, $list [, $begin [, $end [, $enclose ]]] ) |
| An Advanced PHP for Beginners Example | |
| The (X)HTML Output | |
| Final Result | |
| object Lister | top |
Creates a new list object.
<?php
$list = new Lister;
?>
| string ordered ( array $list [, array $enclose ] ) | top |
Creates an ordered list from the array $list.
<?php
$li[] = 'List';
$li[][] = 'Item 1';
$li[][] = 'Item 2';
$li[][][] = 'Sub Item 2';
$li[] = 'More';
/* The above array's multi-dimensional counterpart would be:
$li[0] = array(1=>'List', 5=>'More');
$li[1] = array(2=>'Item 1', 3=>'Item 2');
$li[3] = array(4=>'Sub Item 2');
*/
$html .= $list->ordered ($li, array('b', 'i'));
?>
| string unordered ( array $list [, array $enclose ] ) | top |
Creates an unordered list from the array $list.
<?php
$html .= $list->unordered ($li);
?>
| string definition ( array $list ) | top |
Creates a definition list from the array $list. This method does not have the enclose option.
<?php
$def['efficiency'] = 'making good, thorough, or careful use of resources; not consuming extra. Especially, making good use of time or energy';
$def['harmonious'] = 'a pleasing combination of elements';
$def['organized'] = 'methodical and efficient in arrangement or function; formed into a structured or coherent whole';
$html .= $list->definition ($def);
?>
| string custom ( string $delimit, array $list [, string $begin [, string $end [, array $enclose ]]] ) | top |
This method allows you to create a custom list in case you don't like the flavors that html offers you.
<?php
$html .= '<pre>' . $list->custom ("\t", $li, '- ', '<br />') . '</pre>';
?>
| An Advanced PHP for Beginners Example: | top |
<?php
$page = new Page;
$page->link('style.css');
$html = '';
$list = new Lister;
$li[] = 'List';
$li[][] = 'Item 1';
$li[][] = 'Item 2';
$li[][][] = 'Sub Item 2';
$li[] = 'More';
$html .= $list->ordered ($li, array('b', 'i'));
$html .= $list->unordered ($li);
$html .= '<pre>' . $list->custom ("\t", $li, '- ', '<br />') . '</pre>';
$def['efficiency'] = 'making good, thorough, or careful use of resources; not consuming extra. Especially, making good use of time or energy';
$def['harmonious'] = 'a pleasing combination of elements';
$def['organized'] = 'methodical and efficient in arrangement or function; formed into a structured or coherent whole';
$html .= $list->definition ($def);
unset ($list);
echo $page->display ($html);
?>
| The (X)HTML Output: | top |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Advanced PHP for Beginners</title>
<meta name="description" content="Advanced PHP for Beginners">
<meta name="keywords" content="Advanced PHP for Beginners">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="http://www.advancedphpforbeginners.com/combine/style.css">
</head>
<body>
<ol>
<li><b><i>List</i></b>
<ol>
<li><b><i>Item 1</i></b></li>
<li><b><i>Item 2</i></b>
<ol>
<li><b><i>Sub Item 2</i></b></li>
</ol></li>
</ol></li>
<li><b><i>More</i></b></li>
</ol>
<ul>
<li>List
<ul>
<li>Item 1</li>
<li>Item 2
<ul>
<li>Sub Item 2</li>
</ul></li>
</ul></li>
<li>More</li>
</ul><pre>
- List<br>
- Item 1<br>
- Item 2<br>
- Sub Item 2<br>
- More<br></pre>
<dl>
<dt>efficiency</dt>
<dd>making good, thorough, or careful use of resources; not consuming extra. Especially, making good use of time or energy</dd>
<dt>harmonious</dt>
<dd>a pleasing combination of elements</dd>
<dt>organized</dt>
<dd>methodical and efficient in arrangement or function; formed into a structured or coherent whole</dd>
</dl>
</body>
</html>| Final Result: | top |