Annotation of embedaddon/php/ext/standard/tests/array/array_diff_variation9.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_diff() function : usage variations - multidimensional arrays
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : array array_diff(array $arr1, array $arr2 [, array ...])
! 6: * Description: Returns the entries of arr1 that have values which are
! 7: * not present in any of the others arguments.
! 8: * Source code: ext/standard/array.c
! 9: */
! 10:
! 11: /*
! 12: * Test how array_diff() compares multidimensional arrays
! 13: */
! 14:
! 15: echo "*** Testing array_diff() : usage variations ***\n";
! 16:
! 17: $array1 = array('sub_array1' => array (1, 2, 3),
! 18: 'sub_array2' => array ('a', 'b', 'c'));
! 19: $array2 = array('sub_arraya' => array (1, 3, 5),
! 20: 'sub_arrayb' => array ('a', 'z', 'y'));
! 21:
! 22: echo "-- Compare two 2-D arrays --\n";
! 23: var_dump(array_diff($array1, $array2));
! 24: var_dump(array_diff($array2, $array1));
! 25:
! 26: echo "\n-- Compare subarrays from two 2-D arrays --\n";
! 27: var_dump(array_diff($array1['sub_array1'], $array2['sub_arraya']));
! 28: var_dump(array_diff($array2['sub_arraya'], $array1['sub_array1']));
! 29:
! 30: var_dump(array_diff($array1['sub_array2'], $array2['sub_arrayb']));
! 31: var_dump(array_diff($array2['sub_arrayb'], $array1['sub_array1']));
! 32:
! 33: echo "\n-- Compare a subarray from one 2-D array and one 2-D array --\n";
! 34: var_dump(array_diff($array1['sub_array1'], $array2));
! 35: var_dump(array_diff($array1, $array2['sub_arraya']));
! 36:
! 37: echo "Done";
! 38: ?>
! 39: --EXPECTF--
! 40: *** Testing array_diff() : usage variations ***
! 41: -- Compare two 2-D arrays --
! 42: array(0) {
! 43: }
! 44: array(0) {
! 45: }
! 46:
! 47: -- Compare subarrays from two 2-D arrays --
! 48: array(1) {
! 49: [1]=>
! 50: int(2)
! 51: }
! 52: array(1) {
! 53: [2]=>
! 54: int(5)
! 55: }
! 56: array(2) {
! 57: [1]=>
! 58: string(1) "b"
! 59: [2]=>
! 60: string(1) "c"
! 61: }
! 62: array(3) {
! 63: [0]=>
! 64: string(1) "a"
! 65: [1]=>
! 66: string(1) "z"
! 67: [2]=>
! 68: string(1) "y"
! 69: }
! 70:
! 71: -- Compare a subarray from one 2-D array and one 2-D array --
! 72: array(3) {
! 73: [0]=>
! 74: int(1)
! 75: [1]=>
! 76: int(2)
! 77: [2]=>
! 78: int(3)
! 79: }
! 80: array(2) {
! 81: ["sub_array1"]=>
! 82: array(3) {
! 83: [0]=>
! 84: int(1)
! 85: [1]=>
! 86: int(2)
! 87: [2]=>
! 88: int(3)
! 89: }
! 90: ["sub_array2"]=>
! 91: array(3) {
! 92: [0]=>
! 93: string(1) "a"
! 94: [1]=>
! 95: string(1) "b"
! 96: [2]=>
! 97: string(1) "c"
! 98: }
! 99: }
! 100: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>