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, 01 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

Descrierea

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.

Parametri

coll

Collator object.

str1

The first string to compare.

str2

The second string to compare.

Valorile întroarse

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.

Avertizare

Această funcţie poate întoarce valoarea Boolean FALSE, dar poate de asemenea întoarce o valoare non-Boolean care evaluează în FALSE, cum ar fi 0 sau "". Vă rugăm să citiţi secţiunea despre tipul Boolean pentru mai multe informaţii. Utilizaţi operatorul === pentru a verifica valoarea întoarsă de această funcţie.

Exemple

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

Exemplul de mai sus va afişa:

     s1 is greater than s2
    

Vedeţi de asemenea



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, 01 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites