Query: xdiff_string_diff
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
XDIFF_STRING_DIFF(3) 1 XDIFF_STRING_DIFF(3) xdiff_string_diff - Make unified diff of two stringsSYNOPSISstring xdiff_string_diff (string $old_data, string $new_data, [int $context = 3], [bool $minimal = false])DESCRIPTIONMakes an unified diff containing differences between $old_data string and $new_data string and returns it. The resulting diff is human- readable. An optional $context parameter specifies how many lines of context should be added around each change. Setting $minimal parameter to true will result in outputting the shortest patch file possible (can take a long time).PARAMETERSo $old_data - First string with data. It acts as "old" data. o $new_data - Second string with data. It acts as "new" data. o $context - Indicates how many lines of context you want to include in the diff result. o $minimal - Set this parameter to TRUE if you want to minimalize the size of the result (can take a long time).RETURN VALUESReturns string with resulting diff or FALSE if an internal error happened.EXAMPLESExample #1 xdiff_string_diff(3) example The following code makes unified diff of two articles. <?php $old_article = file_get_contents('./old_article.txt'); $new_article = $_REQUEST['article']; /* Let's say that someone pasted a new article to html form */ $diff = xdiff_string_diff($old_article, $new_article, 1); if (is_string($diff)) { echo "Differences between two articles: "; echo $diff; } ?>NOTESNote This function doesn't work well with binary strings. To make diff of binary strings use xdiff_string_bdiff(3)/xdiff_string_rabd- iff(3).SEE ALSOxdiff_string_patch(3). PHP Documentation Group XDIFF_STRING_DIFF(3)
Related Man Pages |
---|
xdiff_file_diff(3) - php |
xdiff_file_bpatch(3) - php |
xdiff_file_diff_binary(3) - php |
xdiff_file_patch(3) - php |
xdiff_string_rabdiff(3) - php |
Similar Topics in the Unix Linux Community |
---|
Display from a variable using echo. |
Need help with Scripting diff command |
urlwatch 1.4 (Default branch) |
bc question |
Searching for .diff viewer |