reference/intl/collator/compare.xml
1976eae0d815797af97a1e16c5cd90ffc2868395
...
...
@@ -12,22 +12,19 @@
12
12
<para>
13
13
&style.oop;
14
14
</para>
15
-
<methodsynopsis>
16
-
<modifier>public</modifier>
17
-
<type>int</type>
18
-
<methodname>Collator::compare</methodname>
19
-
<methodparam><type>string</type><parameter>str1</parameter></methodparam>
20
-
<methodparam><type>string</type><parameter>str2</parameter></methodparam>
15
+
<methodsynopsis role="Collator">
16
+
<modifier>public</modifier> <type class="union"><type>int</type><type>false</type></type><methodname>Collator::compare</methodname>
17
+
<methodparam><type>string</type><parameter>string1</parameter></methodparam>
18
+
<methodparam><type>string</type><parameter>string2</parameter></methodparam>
21
19
</methodsynopsis>
22
20
<para>
23
21
&style.procedural;
24
22
</para>
25
23
<methodsynopsis>
26
-
<type>int</type>
27
-
<methodname>collator_compare</methodname>
28
-
<methodparam><type>Collator</type><parameter>coll</parameter></methodparam>
29
-
<methodparam><type>string</type><parameter>str1</parameter></methodparam>
30
-
<methodparam><type>string</type><parameter>str2</parameter></methodparam>
24
+
<type class="union"><type>int</type><type>false</type></type><methodname>collator_compare</methodname>
25
+
<methodparam><type>Collator</type><parameter>object</parameter></methodparam>
26
+
<methodparam><type>string</type><parameter>string1</parameter></methodparam>
27
+
<methodparam><type>string</type><parameter>string2</parameter></methodparam>
31
28
</methodsynopsis>
32
29
<para>
33
30
Compare two Unicode strings according to collation rules.
...
...
@@ -39,7 +36,7 @@
39
36
<para>
40
37
<variablelist>
41
38
<varlistentry>
42
-
<term><parameter>coll</parameter></term>
39
+
<term><parameter>object</parameter></term>
43
40
<listitem>
44
41
<para>
45
42
<classname>Collator</classname> object.
...
...
@@ -47,7 +44,7 @@
47
44
</listitem>
48
45
</varlistentry>
49
46
<varlistentry>
50
-
<term><parameter>str1</parameter></term>
47
+
<term><parameter>string1</parameter></term>
51
48
<listitem>
52
49
<para>
53
50
The first string to compare.
...
...
@@ -55,7 +52,7 @@
55
52
</listitem>
56
53
</varlistentry>
57
54
<varlistentry>
58
-
<term><parameter>str2</parameter></term>
55
+
<term><parameter>string2</parameter></term>
59
56
<listitem>
60
57
<para>
61
58
The second string to compare.
...
...
@@ -73,27 +70,24 @@
73
70
<itemizedlist>
74
71
<listitem>
75
72
<para>
76
-
1 if <parameter>str1</parameter> is <emphasis>greater</emphasis> than
77
-
<parameter>str2</parameter> ;
73
+
1 if <parameter>string1</parameter> is <emphasis>greater</emphasis> than
74
+
<parameter>string2</parameter> ;
78
75
</para>
79
76
</listitem>
80
77
<listitem>
81
78
<para>
82
-
0 if <parameter>str1</parameter> is <emphasis>equal</emphasis> to
83
-
<parameter>str2</parameter>;
79
+
0 if <parameter>string1</parameter> is <emphasis>equal</emphasis> to
80
+
<parameter>string2</parameter>;
84
81
</para>
85
82
</listitem>
86
83
<listitem>
87
84
<para>
88
-
-1 if <parameter>str1</parameter> is <emphasis>less</emphasis> than
89
-
<parameter>str2</parameter> .
85
+
-1 if <parameter>string1</parameter> is <emphasis>less</emphasis> than
86
+
<parameter>string2</parameter> .
90
87
</para>
91
88
</listitem>
92
89
</itemizedlist>
93
-
On error
94
-
<type>boolean</type>
95
-
&false;
96
-
is returned.
90
+
Returns &false; on failure.
97
91
</para>
98
92
&return.falseproblem;
99
93
</refsect1>
...
...
@@ -102,7 +96,7 @@
102
96
&reftitle.examples;
103
97
<para>
104
98
<example>
105
-
<title><function>collator_compare</function>example</title>
99
+
<title><function>collator_compare</function> example</title>
106
100
<programlisting role="php">
107
101
<![CDATA[
108
102
<?php
...
...
@@ -130,6 +124,33 @@ if ($res === false) {
130
124
</screen>
131
125
</example>
132
126
</para>
127
+
<para>
128
+
<example>
129
+
<title>Comparing strings without diacritics or case-sensitivity</title>
130
+
<programlisting role="php">
131
+
<![CDATA[
132
+
<?php
133
+
$c = new Collator( 'en' );
134
+
$c->setStrength( Collator::PRIMARY );
135
+

136
+
if ( $c->compare( 'Séan', 'Sean' ) == 0 )
137
+
{
138
+
echo "The same\n";
139
+
}
140
+
]]>
141
+
</programlisting>
142
+
&example.outputs;
143
+
<screen>
144
+
The same
145
+
</screen>
146
+
<para>
147
+
This example instructs the collator to compare with only taking the base
148
+
characters into account. The documentation for
149
+
<function>Collator->setStrength</function> explains the different
150
+
strengths.
151
+
</para>
152
+
</example>
153
+
</para>
133
154
</refsect1>
134
155

135
156
<refsect1 role="seealso">
...
...
@@ -141,7 +162,6 @@ if ($res === false) {
141
162
</para>
142
163
</refsect1>
143
164
</refentry>
144
-

145
165
<!-- Keep this comment at the end of the file
146
166
Local variables:
147
167
mode: sgml
148
168