PHP ARRAY SORTING FUNCTIONS - PHP LESSON 15 STUDENTSBLOG100 - Anna University Multiple Choice Questions

PHP ARRAY SORTING FUNCTIONS - PHP LESSON 15 STUDENTSBLOG100


Generally sorting refers to arranging or ordering data based on some category. In php also sorting functions are used to order the array elements.

Some of the sorting functions are..


Example program for sort():
  • Sort arrays in ascending order 
Output:
1
2
3
4
5

Example program for rsort():
  • Sort arrays in descending order 
Output:
5
4
3
2
1

Example program for asort():
Output:
10
20
30
40

Example program for arsort():
Output:
40
30
20
10

Example program for ksort():
Output:
10
40
20
30

Example program for krsort():
Output:
30
20
40
10

Lesson 14 Previous | Main Page | Next Lesson 16

No comments:

Post a Comment