public static function toTable($diff, $indentation = '', $separator = '<br />')
    {
        // initialise the HTML
        $html = $indentation . "<table class=\"diff\">\n";

        // loop over the lines in the diff
        $index = 0;
        while ($index < count($diff)) {
            // determine the line type
            switch ($diff[$index][1]) {
                // display the content on the left and right
                case self::UNMODIFIED:
                    $leftCell =
                        self::getCellContent(
                            $diff,
                            $indentation,
                            $separator,
                            $index,
                            self::UNMODIFIED
                        );
                    $rightCell = $leftCell;
                    break;

                // display the deleted on the left and inserted content on the right
                case self::DELETED:
                    $leftCell =
                        self::getCellContent(
                            $diff,
                            $indentation,
                            $separator,
                            $index,
                            self::DELETED
                        );
                    $rightCell =
                        self::getCellContent(
                            $diff,
                            $indentation,
                            $separator,
                            $index,
                            self::INSERTED
                        );
                    break;

                // display the inserted content on the right
                case self::INSERTED:
                    $leftCell = '';
                    $rightCell =
                        self::getCellContent(
                            $diff,
                            $indentation,
                            $separator,
                            $index,
                            self::INSERTED
                        );
                    break;

                default:
                    throw new Exception('Undefined type ('.$diff[$index][1].').');
            }

            // extend the HTML with the new row
            $html .=
                $indentation
                . "  <tr>\n"
                . $indentation
                . '    <td class="diff'
                . ($leftCell == $rightCell
                    ? 'Unmodified'
                    : ($leftCell == '' ? 'Blank' : 'Deleted'))
                . '">'
                . $leftCell
                . "</td>\n"
                . $indentation
                . '    <td class="diff'
                . ($leftCell == $rightCell
                    ? 'Unmodified'
                    : ($rightCell == '' ? 'Blank' : 'Inserted'))
                . '">'
                . $rightCell
                . "</td>\n"
                . $indentation
                . "  </tr>\n";
        }

        return $html . $indentation . "</table>\n";
    }
public static function toTable($diff, $indentation = '', $separator = '<br />')
    {
        // initialise the HTML
        $html = $indentation . "<table class=\"diff\">\n";

        // loop over the lines in the diff
        $index = 0;
        while ($index < count($diff)) {
            // determine the line type
            switch ($diff[$index][1]) {
                // display the content on the left and right
                case self::UNMODIFIED:
                    $leftCell =
                        self::getCellContent(
                            $diff,
                            $indentation,
                            $separator,
                            $index,
                            self::UNMODIFIED
                        );
                    $rightCell = $leftCell;
                    break;

                // display the deleted on the left and inserted content on the right
                case self::DELETED:
                    $leftCell =
                        self::getCellContent(
                            $diff,
                            $indentation,
                            $separator,
                            $index,
                            self::DELETED
                        );
                    $rightCell =
                        self::getCellContent(
                            $diff,
                            $indentation,
                            $separator,
                            $index,
                            self::INSERTED
                        );
                    break;

                // display the inserted content on the right
                case self::INSERTED:
                    $leftCell = '';
                    $rightCell =
                        self::getCellContent(
                            $diff,
                            $indentation,
                            $separator,
                            $index,
                            self::INSERTED
                        );
                    break;

                default:
                    throw new Exception('Undefined type ('.$diff[$index][1].').');
            }

            // extend the HTML with the new row
            $html .=
                $indentation
                . "  <tr>\n"
                . $indentation
                . '    <td class="diff'
                . ($leftCell == $rightCell
                    ? 'Unmodified'
                    : ($leftCell == '' ? 'Blank' : 'Deleted'))
                . '">'
                . $leftCell
                . "</td>\n"
                . $indentation
                . '    <td class="diff'
                . ($leftCell == $rightCell
                    ? 'Unmodified'
                    : ($rightCell == '' ? 'Blank' : 'Inserted'))
                . '">'
                . $rightCell
                . "</td>\n"
                . $indentation
                . "  </tr>\n";
        }

        return $html . $indentation . "</table>\n";
    }
public static function toTable ( $ diff , $ indentation = '' , $ separator = '<br />' ) { // initialise the HTML $ html = $ indentation . "<table class=\"diff\">\n" ; // loop over the lines in the diff $ index = 0 ; while ( $ index < count ( $ diff ) ) { // determine the line type switch ( $ diff [ $ index ] [ 1 ] ) { // display the content on the left and right case self :: UNMODIFIED : $ leftCell = self :: getCellContent ( $ diff , $ indentation , $ separator , $ index , self :: UNMODIFIED ) ; $ rightCell = $ leftCell ; break ; // display the deleted on the left and inserted content on the right case self :: DELETED : $ leftCell = self :: getCellContent ( $ diff , $ indentation , $ separator , $ index , self :: DELETED ) ; $ rightCell = self :: getCellContent ( $ diff , $ indentation , $ separator , $ index , self :: INSERTED ) ; break ; // display the inserted content on the right case self :: INSERTED : $ leftCell = '' ; $ rightCell = self :: getCellContent ( $ diff , $ indentation , $ separator , $ index , self :: INSERTED ) ; break ; default : throw new Exception ( 'Undefined type (' . $ diff [ $ index ] [ 1 ] . ').' ) ; } // extend the HTML with the new row $ html .= $ indentation . "  <tr>\n" . $ indentation . '    <td class="diff' . ( $ leftCell == $ rightCell ? 'Unmodified' : ( $ leftCell == '' ? 'Blank' : 'Deleted' ) ) . '">' . $ leftCell . "</td>\n" . $ indentation . '    <td class="diff' . ( $ leftCell == $ rightCell ? 'Unmodified' : ( $ rightCell == '' ? 'Blank' : 'Inserted' ) ) . '">' . $ rightCell . "</td>\n" . $ indentation . "  </tr>\n" ; } return $ html . $ indentation . "</table>\n" ; }
Returns a diff as an HTML table.

@param array  $diff        the diff array
@param string $indentation indentation to add to every line of the generated HTML; this optional parameter
defaults to ''
@param string $separator   the separator between lines; this optional parameter defaults to '<br />'

@return string return the HTML
@throws Exception
Returns a diff as an HTML table .