Gold Vision Communications / USA
 GOLDVISION.COM
Serving the Multimedia Community since 1989.
German Site | Spanish Site 

 Web Hosting

 Virtual Dedicated Servers

 Domaincheck

 Order

 Order Status

 Support

 Contact us

 Download

 Network

 Network Status

 Webdesign / Templates

 Make Payment

 Terms & Conditions

 Imprint

 Legal Notices

 Privacy Statement
  PHP / ksort
ksort

ksort

(PHP 3, PHP 4 )

ksort -- Sortiert ein Array nach Schlüsseln

Beschreibung

int ksort ( array array [, int sort_flags])

Sortiert ein Array nach Schlüsseln, wobei die Zuordnungen zwischen Schlüssel und Wert erhalten bleiben. Dies ist hauptsächlich bei assoziativen Arrays hilfreich.

Beispiel 1. ksort()

$fruits = array ("d"=>"Zitrone", "a"=>"Orange", "b"=>"Banane", "c"=>"Apfel");
ksort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
    echo "$key = $val\n";
}

Dieses Beispiel würde folgendes ausgeben:

a = Orange
b = Banane
c = Apfel
d = Zitrone

Sie können das Verhalten der Sortierung mittels dem optionalen Parameter sort_flags beeinflussen, für Details siehe sort().

Siehe auch asort(), arsort(), krsort(), uksort(), sort(), natsort() und rsort().

Anmerkung: Der zweite Parameter wurde mit PHP 4 eingeführt.


© 1998-2007 Gold Vision Communications All Rights Reserved.