Minggu, 10 Januari 2010

PHP : URUT ARAY 1

$teman = array ("2"=>"Meilana", "4"=>"Ali", "3"=>"Zezen", "1" => "Udin");
print "Data aslinya adalah :
";
foreach ($teman as $tampil => $hasil)
{
print "$tampil = $hasil
";
}

print "Pengurutan data secara ascending
";

ksort($teman);
foreach ($teman as $tampil => $hasil)
{
print "$tampil = $hasil
";
}

print "Pengurutan data secara descending :
";
krsort($teman);
foreach ($teman as $tampil => $hasil)
{
print "$tampil = $hasil
";
}
?>

Tidak ada komentar: