<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="collator.compare" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>Collator::compare</refname>
  <refname>collator_compare</refname>
  <refpurpose>Compare two Unicode strings</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <para>
   &style.oop;
  </para>
  <methodsynopsis role="Collator">
   <modifier>public</modifier> <type class="union"><type>int</type><type>false</type></type><methodname>Collator::compare</methodname>
   <methodparam><type>string</type><parameter>string1</parameter></methodparam>
   <methodparam><type>string</type><parameter>string2</parameter></methodparam>
  </methodsynopsis>
  <para>
   &style.procedural;
  </para>
  <methodsynopsis>
   <type class="union"><type>int</type><type>false</type></type><methodname>collator_compare</methodname>
   <methodparam><type>Collator</type><parameter>object</parameter></methodparam>
   <methodparam><type>string</type><parameter>string1</parameter></methodparam>
   <methodparam><type>string</type><parameter>string2</parameter></methodparam>
  </methodsynopsis>
  <para>
   Compare two Unicode strings according to collation rules.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>object</parameter></term>
     <listitem>
      <para>
       <classname>Collator</classname> object.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>string1</parameter></term>
     <listitem>
      <para>
       The first string to compare.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>string2</parameter></term>
     <listitem>
      <para>
       The second string to compare.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>Return comparison result:</para>
  <para>
   <itemizedlist>
    <listitem>
     <para>
      1 if <parameter>string1</parameter> is <emphasis>greater</emphasis> than 
      <parameter>string2</parameter> ;
     </para>
    </listitem>
    <listitem>
     <para>
      0 if <parameter>string1</parameter> is <emphasis>equal</emphasis> to 
      <parameter>string2</parameter>;
     </para>
    </listitem>
    <listitem>
     <para>
      -1 if <parameter>string1</parameter> is <emphasis>less</emphasis> than 
      <parameter>string2</parameter> .
     </para>
    </listitem>
   </itemizedlist>
   Returns &false; on failure.
  </para>
  &return.falseproblem;
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>collator_compare</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$s1 = 'Hello';
$s2 = 'hello';

$coll = collator_create( 'en_US' );
$res  = collator_compare( $coll, $s1, $s2 );

if ($res === false) {
    echo collator_get_error_message( $coll );
} else if( $res > 0 ) {
    echo "s1 is greater than s2\n";
} else if( $res < 0 ) {
    echo "s1 is less than s2\n";
} else {
    echo "s1 is equal to s2\n";
}
?>
]]>
    </programlisting>
    &example.outputs;
    <screen>
     s1 is greater than s2
    </screen>
   </example>
  </para>
  <para>
   <example>
    <title>Comparing strings without diacritics or case-sensitivity</title>
    <programlisting role="php">
<![CDATA[
<?php
$c = new Collator( 'en' );
$c->setStrength( Collator::PRIMARY );

if ( $c->compare( 'Séan', 'Sean' ) == 0 )
{
    echo "The same\n";
}
]]>
    </programlisting>
    &example.outputs;
    <screen>
     The same
    </screen>
    <para>
     This example instructs the collator to compare with only taking the base
     characters into account. The documentation for
     <function>Collator->setStrength</function> explains the different
     strengths.
    </para>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>collator_sort</function></member>
   </simplelist>
  </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:"~/.phpdoc/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
-->
