VOOZH about

URL: https://www.geeksforgeeks.org/php/arrayobject-ksort-function-in-php/

⇱ ArrayObject ksort() Function in PHP - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ArrayObject ksort() Function in PHP

Last Updated : 11 Jul, 2025
The ksort() function of the ArrayObject class in PHP is used to sort the elements of the ArrayObject according to the keys. This function does not affects the association of the keys with the values, it just sorts the entries of the ArrayObject according to the Keys. Syntax:
void ksort() 
Parameters: This function does not accepts any parameters. Return Value: This function does not returns any value. Below programs illustrate the above function: Program 1:
Output:
ArrayObject Object
(
 [storage:ArrayObject:private] => Array
 (
 [a] => awesome
 [b] => geeks
 [c][/c] => are
 )

)
Program 2:
Output:
ArrayObject Object
(
 [storage:ArrayObject:private] => Array
 (
 [10] => awesome
 [45] => geeks
 [92] => are
 )

)
Reference: https://www.php.net/manual/en/arrayobject.ksort.php
Comment