1--TEST-- 2SPL: Test ArrayObject::ksort() function : basic functionality with array based store 3--FILE-- 4<?php 5/* Prototype : int ArrayObject::ksort() 6 * Description: proto int ArrayIterator::ksort() 7 * Sort the entries by key. 8 * Source code: ext/spl/spl_array.c 9 * Alias to functions: 10 */ 11 12echo "*** Testing ArrayObject::ksort() : basic functionality ***\n"; 13$ao1 = new ArrayObject(array(4,2,3)); 14$ao2 = new ArrayObject(array('b'=>4,'a'=>2,'q'=>3, 99=>'x')); 15var_dump($ao1->ksort()); 16var_dump($ao1); 17var_dump($ao2->ksort('blah')); 18var_dump($ao2); 19var_dump($ao2->ksort(SORT_STRING)); 20var_dump($ao2); 21?> 22===DONE=== 23--EXPECTF-- 24*** Testing ArrayObject::ksort() : basic functionality *** 25bool(true) 26object(ArrayObject)#%d (1) { 27 ["storage":"ArrayObject":private]=> 28 array(3) { 29 [0]=> 30 int(4) 31 [1]=> 32 int(2) 33 [2]=> 34 int(3) 35 } 36} 37 38Warning: ksort() expects parameter 2 to be long, string given in %sarrayObject_ksort_basic1.php on line %d 39bool(false) 40object(ArrayObject)#2 (1) { 41 ["storage":"ArrayObject":private]=> 42 array(4) { 43 ["b"]=> 44 int(4) 45 ["a"]=> 46 int(2) 47 ["q"]=> 48 int(3) 49 [99]=> 50 string(1) "x" 51 } 52} 53bool(true) 54object(ArrayObject)#%d (1) { 55 ["storage":"ArrayObject":private]=> 56 array(4) { 57 [99]=> 58 string(1) "x" 59 ["a"]=> 60 int(2) 61 ["b"]=> 62 int(4) 63 ["q"]=> 64 int(3) 65 } 66} 67===DONE=== 68