Annotation of embedaddon/php/ext/spl/tests/arrayObject_uasort_basic1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SPL: Test ArrayObject::uasort() function : basic functionality
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : int ArrayObject::uasort(callback cmp_function)
! 6: * Description: proto int ArrayIterator::uasort(callback cmp_function)
! 7: Sort the entries by values user defined function.
! 8: * Source code: ext/spl/spl_array.c
! 9: * Alias to functions:
! 10: */
! 11:
! 12: echo "*** Testing ArrayObject::uasort() : basic functionality ***\n";
! 13:
! 14: // Reverse sorter
! 15: function cmp($value1, $value2) {
! 16: if($value1 == $value2) {
! 17: return 0;
! 18: }
! 19: else if($value1 < $value2) {
! 20: return 1;
! 21: }
! 22: else
! 23: return -1;
! 24: }
! 25: $ao = new ArrayObject(array(2,3,1));
! 26:
! 27: $ao->uasort('cmp');
! 28: var_dump($ao);
! 29: ?>
! 30: ===DONE===
! 31: --EXPECTF--
! 32: *** Testing ArrayObject::uasort() : basic functionality ***
! 33: object(ArrayObject)#1 (1) {
! 34: ["storage":"ArrayObject":private]=>
! 35: array(3) {
! 36: [1]=>
! 37: int(3)
! 38: [0]=>
! 39: int(2)
! 40: [2]=>
! 41: int(1)
! 42: }
! 43: }
! 44: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>