xdiff_string_diff
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
xdiff_string_diff
Референца за `function.xdiff-string-diff.php` со подобрена типографија и навигација.
xdiff_string_diff
(PECL xdiff >= 0.2.0)
xdiff_string_diff — Make unified diff of two strings
= NULL
string
$old_data,string
$new_data,int
$context = 3,bool
$minimal = false): string
Прави унифицирана разлика што содржи разлики помеѓу old_data string and
new_data string and returns it. The resulting diff is human-readable. An optional context параметар специфицира колку редови контекст треба да се додадат околу секоја промена. Поставување minimal параметар на true ќе резултира со испишување на најкратката можна датотека со лепенка (може да потрае долго).
Параметри
old_data-
Прва низа со податоци. Таа делува како „стари“ податоци.
new_data-
Second string with data. It acts as "new" data.
context-
Indicates how many lines of context you want to include in the diff result.
minimal-
Поставете го овој параметар на
trueif you want to minimalize the size of the result (can take a long time).
Вратени вредности
Returns string with resulting diff or false Враќа низ со резултат или
Примери
Пример #1 xdiff_string_diff() 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:\n";
echo $diff;
}
?>Белешки
Забелешка:
This function doesn't work well with binary strings. To make diff of binary strings use xdiff_string_bdiff()/xdiff_string_rabdiff().