A list is represented by the class ODTList
. A list can have a sublist, which is represented by the class ODTSubList
.
To create a list, we call the constructor of the class ODTList
. If we dont't pass any argument, the created list will be empty; we can also pass an array that represents the items of the list.
$list = new ODTList(array('item1', 'item2', 'item3'));
To add items to an existing list, we use addItem($item)
.
$list->addItem('Item4');
A sublist is represented by the class ODTSubList
. Same as ODTList
, we can pass an array of items to the constructor, or we can call it without arguments to create an empty sublist; also, we can add items to an existing sublist using the method addItem
.
$list = new ODTList(array('item1', 'item2', 'item3')); $sublist = new ODTSubList(array('item3.1', 'item3.2')); $sublist->addItem('item3.3'); $list->addSubList($sublist);