PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Collator::__construct> <Collator::asort
Last updated: Fri, 22 Aug 2008

view this page in

Collator::compare

collator_compare

(No version information available, might be only in CVS)

Collator::compare -- collator_compareCompare two Unicode strings

Descripción

Object oriented style

integer Collator::compare ( string $str1 , string $str2 )

Procedural style

integer collator_compare ( Collator $coll , string $str1 , string $str2 )

Compare two Unicode strings according to collation rules.

Lista de parámetros

coll

Collator object.

str1

The first string to compare.

str2

The second string to compare.

Valores retornados

Return comparison result:

  • 1 if str1 is greater than str2 ;

  • 0 if str1 is equal to str2;

  • -1 if str1 is less than str2 .

On error boolean FALSE is returned.

Warning

Esta función puede devolver FALSE, pero también puede devolver un valor no-booleano que será evaluado FALSE, como por ejemplo 0 o "". Por favor, lea la sección Booleans para más información. Utilice el operador === para comprobar el valor devuelto por esta función.

Ejemplos

Example #1 collator_compare()example

<?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 ) {
    echo 
"s1 is greater than s2\n";
} else if( 
$res ) {
    echo 
"s1 is less than s2\n";
} else {
    echo 
"s1 is equal to s2\n";
?>

El resultado del ejemplo seria:

     s1 is greater than s2
    

Ver también



add a note add a note User Contributed Notes
Collator::compare
There are no user contributed notes for this page.

Collator::__construct> <Collator::asort
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites