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, 10 Oct 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

Description

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.

Liste de paramètres

coll

Collator object.

str1

The first string to compare.

str2

The second string to compare.

Valeurs de retour

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.

Avertissement

Cette fonction peut retourner FALSE, mais elle peut aussi retourner une valeur équivalent à FALSE, utilisable dans une condition if simple. Utilisez l'opérateur === pour tester la valeur de retour exacte de cette fonction.

Exemples

Exemple #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";
?>

L'exemple ci-dessus va afficher :

     s1 is greater than s2
    

Voir aussi



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, 10 Oct 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites