Query: xdiff_string_patch
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
XDIFF_STRING_PATCH(3) 1 XDIFF_STRING_PATCH(3) xdiff_string_patch - Patch a string with an unified diffSYNOPSISstring xdiff_string_patch (string $str, string $patch, [int $flags], [string &$error])DESCRIPTIONPatches a $str string with an unified patch in $patch parameter and returns the result. $patch has to be an unified diff created by xdiff_file_diff(3)/xdiff_string_diff(3) function. An optional $flags parameter specifies mode of operation. Any rejected parts of the patch will be stored inside $error variable if it is provided.PARAMETERSo $str - The original string. o $patch - The unified patch string. It has to be created using xdiff_string_diff(3), xdiff_file_diff(3) functions or compatible tools. o $flags -$flags can be either XDIFF_PATCH_NORMAL (default mode, normal patch) or XDIFF_PATCH_REVERSE (reversed patch). Starting from ver- sion 1.5.0, you can also use binary OR to enable XDIFF_PATCH_IGNORESPACE flag. o $error - If provided then rejected parts are stored inside this variable.RETURN VALUESReturns the patched string, or FALSE on error.EXAMPLESExample #1 xdiff_string_patch(3) example The following code applies changes to some article. <?php $old_article = file_get_contents('./old_article.txt'); $diff = $_SERVER['patch']; /* Let's say that someone pasted a patch to html form */ $errors = ''; $new_article = xdiff_string_patch($old_article, $diff, XDIFF_PATCH_NORMAL, $errors); if (is_string($new_article)) { echo "New article: "; echo $new_article; } if (strlen($errors)) { echo "Rejects: "; echo $errors; } ?>SEE ALSOxdiff_string_diff(3). PHP Documentation Group XDIFF_STRING_PATCH(3)
Related Man Pages |
---|
mrtg-contrib(1) - debian |
patcher(1) - debian |
mrtg-contrib(1) - centos |
mrtg-contrib(1) - suse |
git-patch-id(1) - osx |
Similar Topics in the Unix Linux Community |
---|
Interactive patching? |
Troj_patch.cd |
Need help with Scripting diff command |
urlwatch 1.2 (Default branch) |
urlwatch 1.4 (Default branch) |