public static function toString($diff, $separator = "\n")
    {
        // initialise the string
        $string = '';

        // loop over the lines in the diff
        foreach ($diff as $line) {
            // extend the string with the line
            switch ($line[1]) {
                case self::UNMODIFIED:
                    $string .= '  ' . $line[0];
                    break;
                case self::DELETED:
                    $string .= '- ' . $line[0];
                    break;
                case self::INSERTED:
                    $string .= '+ ' . $line[0];
                    break;
                default:
                    throw new Exception('Undefined type ('.$line[1].').');
            }

            // extend the string with the separator
            $string .= $separator;
        }

        return $string;
    }
public static function toString($diff, $separator = "\n")
    {
        // initialise the string
        $string = '';

        // loop over the lines in the diff
        foreach ($diff as $line) {
            // extend the string with the line
            switch ($line[1]) {
                case self::UNMODIFIED:
                    $string .= '  ' . $line[0];
                    break;
                case self::DELETED:
                    $string .= '- ' . $line[0];
                    break;
                case self::INSERTED:
                    $string .= '+ ' . $line[0];
                    break;
                default:
                    throw new Exception('Undefined type ('.$line[1].').');
            }

            // extend the string with the separator
            $string .= $separator;
        }

        return $string;
    }
public static function toString ( $ diff , $ separator = "\n" ) { // initialise the string $ string = '' ; // loop over the lines in the diff foreach ( $ diff as $ line ) { // extend the string with the line switch ( $ line [ 1 ] ) { case self :: UNMODIFIED : $ string .= '  ' . $ line [ 0 ] ; break ; case self :: DELETED : $ string .= '- ' . $ line [ 0 ] ; break ; case self :: INSERTED : $ string .= '+ ' . $ line [ 0 ] ; break ; default : throw new Exception ( 'Undefined type (' . $ line [ 1 ] . ').' ) ; } // extend the string with the separator $ string .= $ separator ; } return $ string ; }
Returns a diff as a string, where unmodified lines are prefixed by '  ', deletions are prefixed by '- ', and
insertions are prefixed by '+ '.

@param array  $diff      the diff array
@param string $separator the separator between lines; this optional parameter defaults to "\n"

@return string string
Returns a diff as a string where unmodified lines are prefixed by deletions are prefixed by - and insertions are prefixed by + .