CI_Table::make_columns PHP Méthode

make_columns() public méthode

Set columns. Takes a one-dimensional array as input and creates a multi-dimensional array with a depth equal to the number of columns. This allows a single array with many elements to be displayed in a table that has a fixed column count.
public make_columns ( array $array = [], integer $col_limit ) : array
$array array
$col_limit integer
Résultat array
    public function make_columns($array = array(), $col_limit = 0)
    {
        if (!is_array($array) or count($array) === 0 or !is_int($col_limit)) {
            return FALSE;
        }
        // Turn off the auto-heading feature since it's doubtful we
        // will want headings from a one-dimensional array
        $this->auto_heading = FALSE;
        if ($col_limit === 0) {
            return $array;
        }
        $new = array();
        do {
            $temp = array_splice($array, 0, $col_limit);
            if (count($temp) < $col_limit) {
                for ($i = count($temp); $i < $col_limit; $i++) {
                    $temp[] = '&nbsp;';
                }
            }
            $new[] = $temp;
        } while (count($array) > 0);
        return $new;
    }