This repository was archived by the owner on Jun 18, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class Table {
2727 protected $ _footers = array ();
2828 protected $ _width = array ();
2929 protected $ _rows = array ();
30+ protected $ _use_index = false ;
3031
3132 /**
3233 * Initializes the `Table` class.
@@ -79,6 +80,7 @@ public function resetTable()
7980 $ this ->_width = array ();
8081 $ this ->_rows = array ();
8182 $ this ->_footers = array ();
83+ $ this ->_use_index = false ;
8284 return $ this ;
8385 }
8486
@@ -212,6 +214,14 @@ public function addRow(array $row) {
212214 $ this ->_rows [] = $ this ->checkRow ($ row );
213215 }
214216
217+ /**
218+ * Sets if we should output the arrays index
219+ */
220+ public function useIndex ()
221+ {
222+ $ this ->_use_index = true ;
223+ }
224+
215225 /**
216226 * Clears all previous rows and adds the given rows.
217227 *
@@ -220,7 +230,10 @@ public function addRow(array $row) {
220230 */
221231 public function setRows (array $ rows ) {
222232 $ this ->_rows = array ();
223- foreach ($ rows as $ row ) {
233+ foreach ($ rows as $ id => $ row ) {
234+ if ($ this ->_use_index === true ) {
235+ $ row = array_merge (array ($ id ), $ row );
236+ }
224237 $ this ->addRow ($ row );
225238 }
226239 }
You can’t perform that action at this time.
0 commit comments