<?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.4 $ --> <!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. --> <refentry id="function.xdiff-string-diff"> <refnamediv> <refname>xdiff_string_diff</refname> <refpurpose> Make unified diff of two strings </refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>mixed</type><methodname>xdiff_string_diff</methodname> <methodparam><type>string</type><parameter>str1</parameter></methodparam> <methodparam><type>string</type><parameter>str2</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>context</parameter></methodparam> <methodparam choice="opt"><type>bool</type><parameter>minimal</parameter></methodparam> </methodsynopsis> <para> <function>xdiff_string_diff</function> makes unified diff of strings <parameter>str1</parameter> and <parameter>str2</parameter>. <parameter>context</parameter> indicated how many lines of context you want to include in diff result. Set <parameter>minimal</parameter> to &true; if you want to minimalize size of diff (can take a long time). </para> <note> <para> This function doesn't work well with binary strings. To make diff of binary strings use <function>xdiff_string_diff_binary</function>. </para> </note> <para> Returns string with result or &false; if an internal error happened. </para> <example> <title><function>xdiff_string_diff</function> example</title> <para> The following code makes unified diff of two articles. </para> <programlisting role="php"> <![CDATA[ <?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; } ?> ]]> </programlisting> </example> <para> See also <function>xdiff_file_diff</function>. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->