Home :: International :: Manuals :: Howto :: FAQ :: Man Pages :: Email Login

 
 

 

arsort

(PHP 3, PHP 4 , PHP 5)

arsort --  連想キーと要素との関係を維持しつつ配列を逆順にソートする

説明

void arsort ( array array [, int sort_flags])

この関数は、連想配列において各配列のキーと要素との関係を維持しつ つソートを行います。この関数は、主に実際の要素の並び方が重要であ る連想配列をソートするために使われます。

例 1. arsort()の例

<?php
$fruits
= array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
arsort ($fruits);
reset ($fruits);
while (list (
$key, $val) = each ($fruits)) {
echo
"$key = $val\n";
}
?>

この例は、以下のように出力されます。
a = orange
d = lemon
b = banana
c = apple

fruitsはアルファベットの逆順にソートされ、各要素とキーとの関係は 維持されます。

オプションのパラメータsort_flagsによりソー トの動作を修正可能です。詳細については、sort() を参照下さい。

asort(), rsort(), ksort(), sort() も参照下さい。

 
 
 
 
Google
  Web Linuxinfor   
 

Home :: Copyright :: Privacy :: Credits :: Get a free Linuxinfor Email Account

Document on this page is part of "PHP マニュアル". See Index Page for more info about Authorship and Copyright.

1999-2009 Linuxinfor.com. No rights reserved.