private function splitCellsContent()
    {
        // For each row...
        foreach ($this->data as $rowPosition => $rowContent) {
            // ... cycle each column to get its content
            foreach ($rowContent as $columnName => $cellContent) {
                // Remove extra spaces from the string
                $cellContent = $this->reduceSpaces($cellContent);

                // If we don't have a max width set for the column...
                if (false === isset($this->options['columns'][$columnName]['max_width'])) {
                    // ... simply wrap the content in an array and continue
                    $this->data[$rowPosition][$columnName] = [$cellContent];
                    goto addVerticalPadding;
                }

                // ... We have a max_width set: split the column
                $length = $this->options['columns'][$columnName]['max_width'];
                $cut    = $this->options['columns'][$columnName]['cut'];

                $wrapped = wordwrap($cellContent, $length, PHP_EOL, $cut);

                $this->data[$rowPosition][$columnName] = explode(PHP_EOL, $wrapped);

                // At the end, add the vertical padding to the cell's content
                addVerticalPadding:
                if (0 < $this->options['cells_padding'][0]) {
                    // Now add the top padding
                    for ($paddingLine = 0; $paddingLine < $this->options['cells_padding'][0]; ++$paddingLine) {
                        array_unshift($this->data[$rowPosition][$columnName], '');
                    }
                }

                if (0 < $this->options['cells_padding'][2]) {
                    // And the bottom padding
                    for ($paddingLine = 0; $paddingLine < $this->options['cells_padding'][2]; ++$paddingLine) {
                        array_push($this->data[$rowPosition][$columnName], '');
                    }
                }
            }
        }
    }
private function splitCellsContent()
    {
        // For each row...
        foreach ($this->data as $rowPosition => $rowContent) {
            // ... cycle each column to get its content
            foreach ($rowContent as $columnName => $cellContent) {
                // Remove extra spaces from the string
                $cellContent = $this->reduceSpaces($cellContent);

                // If we don't have a max width set for the column...
                if (false === isset($this->options['columns'][$columnName]['max_width'])) {
                    // ... simply wrap the content in an array and continue
                    $this->data[$rowPosition][$columnName] = [$cellContent];
                    goto addVerticalPadding;
                }

                // ... We have a max_width set: split the column
                $length = $this->options['columns'][$columnName]['max_width'];
                $cut    = $this->options['columns'][$columnName]['cut'];

                $wrapped = wordwrap($cellContent, $length, PHP_EOL, $cut);

                $this->data[$rowPosition][$columnName] = explode(PHP_EOL, $wrapped);

                // At the end, add the vertical padding to the cell's content
                addVerticalPadding:
                if (0 < $this->options['cells_padding'][0]) {
                    // Now add the top padding
                    for ($paddingLine = 0; $paddingLine < $this->options['cells_padding'][0]; ++$paddingLine) {
                        array_unshift($this->data[$rowPosition][$columnName], '');
                    }
                }

                if (0 < $this->options['cells_padding'][2]) {
                    // And the bottom padding
                    for ($paddingLine = 0; $paddingLine < $this->options['cells_padding'][2]; ++$paddingLine) {
                        array_push($this->data[$rowPosition][$columnName], '');
                    }
                }
            }
        }
    }
private function splitCellsContent ( ) { // For each row... foreach ( $ this -> data as $ rowPosition => $ rowContent ) { // ... cycle each column to get its content foreach ( $ rowContent as $ columnName => $ cellContent ) { // Remove extra spaces from the string $ cellContent = $ this -> reduceSpaces ( $ cellContent ) ; // If we don't have a max width set for the column... if ( false === isset ( $ this -> options [ 'columns' ] [ $ columnName ] [ 'max_width' ] ) ) { // ... simply wrap the content in an array and continue $ this -> data [ $ rowPosition ] [ $ columnName ] = [ $ cellContent ] ; goto addVerticalPadding ; } // ... We have a max_width set: split the column $ length = $ this -> options [ 'columns' ] [ $ columnName ] [ 'max_width' ] ; $ cut = $ this -> options [ 'columns' ] [ $ columnName ] [ 'cut' ] ; $ wrapped = wordwrap ( $ cellContent , $ length , PHP_EOL , $ cut ) ; $ this -> data [ $ rowPosition ] [ $ columnName ] = explode ( PHP_EOL , $ wrapped ) ; // At the end, add the vertical padding to the cell's content addVerticalPadding : if ( 0 < $ this -> options [ 'cells_padding' ] [ 0 ] ) { // Now add the top padding for ( $ paddingLine = 0 ; $ paddingLine < $ this -> options [ 'cells_padding' ] [ 0 ] ; ++ $ paddingLine ) { array_unshift ( $ this -> data [ $ rowPosition ] [ $ columnName ] , '' ) ; } } if ( 0 < $ this -> options [ 'cells_padding' ] [ 2 ] ) { // And the bottom padding for ( $ paddingLine = 0 ; $ paddingLine < $ this -> options [ 'cells_padding' ] [ 2 ] ; ++ $ paddingLine ) { array_push ( $ this -> data [ $ rowPosition ] [ $ columnName ] , '' ) ; } } } } }
Splits the content of each cell into multiple lines according to the set max column width.
Splits the content of each cell into multiple lines according to the set max column width .