1// take an array with some elements
2$array = array('a','z','c','b');
3// get the size of array
4$count = count($array);
5echo "<pre>";
6// Print array elements before sorting
7print_r($array);
8for ($i = 0; $i < $count; $i++) {
9 for ($j = $i + 1; $j < $count; $j++) {
10 if ($array[$i] > $array[$j]) {
11 $temp = $array[$i];
12 $array[$i] = $array[$j];
13 $array[$j] = $temp;
14 }
15 }
16}
17echo "Sorted Array:" . "<br/>";
18print_r($array);
19