PHP 5.6.16 is available


(PHP 5 >= 5.2.0)

ArrayObject::ksortSort the entries by key


public void ArrayObject::ksort ( void )

Sorts the entries by key, maintaining key to entry correlations. This is useful mainly for associative arrays.


This function has no parameters.

Return Values

No value is returned.


Example #1 ArrayObject::ksort() example

= array("d" => "lemon""a" => "orange""b" => "banana""c" => "apple");
$fruitArrayObject = new ArrayObject($fruits);

foreach (
$fruitArrayObject as $key => $val) {
"$key = $val\n";

The above example will output:

a = orange
b = banana
c = apple
d = lemon

See Also

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top