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, 18 Jul 2008

view this page in

Collator::compare

collator_compare

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

collator_compare — Compare two Unicode strings

Descrizione

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.

Elenco dei parametri

coll

Collator object.

str1

The first string to compare.

str2

The second string to compare.

Valori restituiti

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.

Avviso

Questa funzione può restituire il Booleano FALSE, ma può anche restituire un valore non-Booleano valutato come FALSE, come ad esempio 0 o "". Per favore fare riferimento alla sezione Booleans per maggiori informazioni. Usare l'operatore === per controllare il valore restituito da questa funzione.

Esempi

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

Il precedente esempio visualizzerà:

     s1 is greater than s2
    

Vedere anche:



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