File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / spl / tests / arrayObject_uasort_basic1.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:01 2012 UTC (12 years, 6 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
SPL: Test ArrayObject::uasort() function : basic functionality 
--FILE--
<?php
/* Prototype  : int ArrayObject::uasort(callback cmp_function)
 * Description: proto int ArrayIterator::uasort(callback cmp_function)
 Sort the entries by values user defined function. 
 * Source code: ext/spl/spl_array.c
 * Alias to functions: 
 */

echo "*** Testing ArrayObject::uasort() : basic functionality ***\n";

// Reverse sorter
function cmp($value1, $value2) {
  if($value1 == $value2) {
    return 0;
  }
  else if($value1 < $value2) {
    return 1;
  }
  else
    return -1;
}
$ao = new ArrayObject(array(2,3,1));

$ao->uasort('cmp');
var_dump($ao);
?>
===DONE===
--EXPECTF--
*** Testing ArrayObject::uasort() : basic functionality ***
object(ArrayObject)#1 (1) {
  ["storage":"ArrayObject":private]=>
  array(3) {
    [1]=>
    int(3)
    [0]=>
    int(2)
    [2]=>
    int(1)
  }
}
===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>