krsort 对数组按照键名逆向排序 php函数


krsort

(PHP 4, PHP 5)

krsort对数组按照键名逆向排序

说明

bool krsort ( array &$array [, int $sort_flags ] )

对数组按照键名逆向排序,保留键名到数据的关联。主要用于结合数组。

成功时返回 TRUE, 或者在失败时返回 FALSE.

Example #1 krsort() 例子

<?php
$fruits 
= array("d"=>"lemon""a"=>"orange""b"=>"banana""c"=>"apple");
krsort($fruits);
foreach (
$fruits as $key => $val) {
    echo 
"$key = $val ";
}
?>

以上例程会输出:

d = lemon
c = apple
b = banana
a = orange

可以用可选参数 sort_flags 改变排序的行为,详情见 sort()

参见 asort()arsort()ksort()sort()natsort()rsort()



相关阅读:
ksort 对数组按照键名排序
lcg_value 组合线性同余发生器
lchgrp Changes group ownership of symlink
lchown Changes user ownership of symlink
ldap_8859_to_t61 Translate 8859 characters to t61 characters
ldap_add Add entries to LDAP directory
ldap_bind Bind to LDAP directory
ldap_close 别名 ldap_unbind
ldap_compare Compare value of attribute found in entry specified with DN
ldap_connect Connect to an LDAP server
ldap_count_entries Count the number of entries in a search
ldap_delete Delete an entry from a directory
ldap_dn2ufn Convert DN to User Friendly Naming format
ldap_err2str Convert LDAP error number into string error message
快速导航

Copyright © 2016 phpStudy |