📜  数组排序php代码示例

📅  最后修改于: 2022-03-11 14:54:31.455000             🧑  作者: Mango

代码示例6
// take an array with some elements
$array = array('a','z','c','b');
// get the size of array
$count = count($array);
echo "
";
// Print array elements before sorting
print_r($array);
for ($i = 0; $i < $count; $i++) {
    for ($j = $i + 1; $j < $count; $j++) {
        if ($array[$i] > $array[$j]) {
            $temp = $array[$i];
            $array[$i] = $array[$j];
            $array[$j] = $temp;
        }
    }
}
echo "Sorted Array:" . "
"; print_r($array);