~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/standard/tests/array/array_diff_ukey_variation5.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Test array_diff_ukey() function : usage variation - Passing multi-dimensional array
 
3
--FILE--
 
4
<?php
 
5
/* Prototype  : array array_diff_ukey(array arr1, array arr2 [, array ...], callback key_comp_func)
 
6
 * Description: Returns the entries of arr1 that have keys which are not present in any of the others arguments. User supplied function is used for comparing the keys. This function is like array_udiff() but works on the keys instead of the values. The associativity is preserved. 
 
7
 * Source code: ext/standard/array.c
 
8
 */
 
9
 
 
10
echo "*** Testing array_diff_ukey() : usage variation ***\n";
 
11
 
 
12
// Initialise function arguments not being substituted (if any)
 
13
$array1 = array(
 
14
 
 
15
          'first' => array('blue' => 1, 'red' => 2),
 
16
              
 
17
      'second' => array('yellow' => 7),
 
18
              
 
19
      'third' => array(0 => 'zero'),
 
20
);
 
21
 
 
22
$array2 = array (
 
23
 
 
24
          'first' => array('blue' => 1, 'red' => 2,),
 
25
              
 
26
      'second' => array('cyan' => 8),
 
27
              
 
28
      'fourth' => array(2 => 'two'), 
 
29
);
 
30
 
 
31
echo "\n-- Testing array_diff_ukey() function with multi dimensional array --\n";
 
32
var_dump( array_diff_ukey($array1, $array2, 'strcasecmp') );
 
33
var_dump( array_diff_ukey($array2, $array1, 'strcasecmp') );
 
34
?>
 
35
===DONE===
 
36
--EXPECTF--
 
37
*** Testing array_diff_ukey() : usage variation ***
 
38
 
 
39
-- Testing array_diff_ukey() function with multi dimensional array --
 
40
array(1) {
 
41
  ["third"]=>
 
42
  array(1) {
 
43
    [0]=>
 
44
    string(4) "zero"
 
45
  }
 
46
}
 
47
array(1) {
 
48
  ["fourth"]=>
 
49
  array(1) {
 
50
    [2]=>
 
51
    string(3) "two"
 
52
  }
 
53
}
 
54
===DONE===