Join Up!
104886 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousuasortusortnext
Last updated: Tue, 29 Oct 2002
view the printer friendly version or the printer friendly version with notes or change language to Czech | German

uksort

(PHP 3>= 3.0.4, PHP 4 )

uksort --  Ordena una matriz por claves mediante una función definida por el usuario

Descripción

void uksort ( array matriz, function func_comparar)

Esta función ordenará las claves de una matriz utilizando una función de comparación suministrada por el usuario. Si la matriz a ordenar necesita utilizar un criterio poco trivial, esta es la función que deberá usar.

Ejemplo 1. Ejemplo de uksort()

function micomparar ($a, $b) {   
    if ($a == $b) return 0;
    return ($a > $b) ? -1 : 1;
}
$a = array (4 => "cuatro", 3 => "tres", 20 => "veinte", 10 => "diez");
uksort ($a, micomparar);
while (list ($clave, $valor) = each ($a)) {
    echo "$clave: $valor\n";
}
Este ejemplo mostrará: 20: veinte 10: diez 4: cuatro 3: tres

Vea también: arsort(), asort(), uasort(), ksort(), rsort(), y sort().

User Contributed Notes
uksort
add a note about notes
There are no user contributed notes for this page.
previousuasortusortnext
Last updated: Tue, 29 Oct 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST