function diff_get_rows in Diff 7.2
Same name and namespace in other branches
- 6.2 diff.module \diff_get_rows()
- 7.3 diff.module \diff_get_rows()
Render a diff of two strings to a $rows array suitable for use with theme('table') or theme('diff_table').
Parameters
string $a: The source string to compare from.
string $b: The target string to compare to.
boolean $show_header: Display diff context headers, e.g. "Line x".
Return value
Array of rows usable with theme('table').
1 call to diff_get_rows()
- _diff_body_rows in ./
diff.pages.inc - Creates an array of rows which represent a diff between $old_node and $new_node. The rows can be used via theme('diff_table') to be displayed.
File
- ./
diff.module, line 284 - Provides functionality to show a diff between two node revisions.
Code
function diff_get_rows($a, $b, $show_header = FALSE) {
$a = is_array($a) ? $a : explode("\n", $a);
$b = is_array($b) ? $b : explode("\n", $b);
module_load_include('php', 'diff', 'DiffEngine');
$formatter = new DrupalDiffFormatter();
$formatter->show_header = $show_header;
$diff = new Diff($a, $b);
return $formatter
->format($diff);
}