source: branches/version-2_5-dev/data/module/Compat/tests/function/array_udiff_uassoc.phpt @ 20119

Revision 20119, 1.1 KB checked in by nanasess, 13 years ago (diff)

module 以下は svn:keywords を除外

  • Property svn:eol-style set to LF
Line 
1--TEST--
2Function -- array_udiff_uassoc
3--SKIPIF--
4<?php if (function_exists('array_udiff_uassoc')) { echo 'skip'; } ?>
5--FILE--
6<?php
7require_once 'PHP/Compat.php';
8PHP_Compat::loadFunction('array_udiff_uassoc');
9
10class cr
11{
12    var $val;
13
14    function cr($val)
15    {
16        $this->val = $val;
17    }
18
19    function comp_func_cr($a, $b)
20    {
21        if ($a->val === $b->val) return 0;
22        return ($a->val > $b->val) ? 1 : -1;
23    }
24   
25    function comp_func_key($a, $b)
26    {
27        if ($a === $b) return 0;
28        return ($a > $b) ? 1 : -1;
29    }
30}
31
32$a = array('0.1' => new cr(9), '0.5' => new cr(12), 0 => new cr(23), 1 => new cr(4), 2 => new cr(-15));
33$b = array('0.2' => new cr(9), '0.5' => new cr(22), 0 => new cr(3), 1 => new cr(4), 2 => new cr(-15));
34
35$result = array_udiff_uassoc($a, $b, array('cr', 'comp_func_cr'), array('cr', 'comp_func_key'));
36print_r($result);
37?>
38--EXPECT--
39Array
40(
41    [0.1] => cr Object
42        (
43            [val] => 9
44        )
45
46    [0.5] => cr Object
47        (
48            [val] => 12
49        )
50
51    [0] => cr Object
52        (
53            [val] => 23
54        )
55
56)
Note: See TracBrowser for help on using the repository browser.