asort()・arsort()・ksort()・krsort()

キー・値の昇順・降順

<?php

$gainers = array('4664:RSC'=>'PER:-','4598:メドレックス'=>'PER:-','3791:IGポート'=>'PER:45.1','2385:総医研HD'=>'PER:63.7','4335:IPS'=>'PER:19.3','9385:ショーエイ'=>'PER:21.2','4976:東洋ドライ'=>'PER:17.8','7446:東北化学'=>'PER:13.2','3842:ネクスジェン'=>'PER:30.3','8705:岡藤HD'=>'PER:-');

asort($gainers);
print_r($gainers);
echo "<br><br>";
arsort($gainers);
print_r($gainers);
echo "<br><br>";
ksort($gainers);
print_r($gainers);
echo "<br><br>";
krsort($gainers);
print_r($gainers);
?>

Array ( [4664:RSC] => PER:- [8705:岡藤HD] => PER:- [4598:メドレックス] => PER:- [7446:東北化学] => PER:13.2 [4976:東洋ドライ] => PER:17.8 [4335:IPS] => PER:19.3 [9385:ショーエイ] => PER:21.2 [3842:ネクスジェン] => PER:30.3 [3791:IGポート] => PER:45.1 [2385:総医研HD] => PER:63.7 )

Array ( [2385:総医研HD] => PER:63.7 [3791:IGポート] => PER:45.1 [3842:ネクスジェン] => PER:30.3 [9385:ショーエイ] => PER:21.2 [4335:IPS] => PER:19.3 [4976:東洋ドライ] => PER:17.8 [7446:東北化学] => PER:13.2 [8705:岡藤HD] => PER:- [4598:メドレックス] => PER:- [4664:RSC] => PER:- )

Array ( [2385:総医研HD] => PER:63.7 [3791:IGポート] => PER:45.1 [3842:ネクスジェン] => PER:30.3 [4335:IPS] => PER:19.3 [4598:メドレックス] => PER:- [4664:RSC] => PER:- [4976:東洋ドライ] => PER:17.8 [7446:東北化学] => PER:13.2 [8705:岡藤HD] => PER:- [9385:ショーエイ] => PER:21.2 )

Array ( [9385:ショーエイ] => PER:21.2 [8705:岡藤HD] => PER:- [7446:東北化学] => PER:13.2 [4976:東洋ドライ] => PER:17.8 [4664:RSC] => PER:- [4598:メドレックス] => PER:- [4335:IPS] => PER:19.3 [3842:ネクスジェン] => PER:30.3 [3791:IGポート] => PER:45.1 [2385:総医研HD] => PER:63.7 )