Annotation of embedaddon/php/ext/standard/tests/array/array_diff_variation4.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_diff() function : usage variations - array with different data types as values
! 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 not
! 7: * present in any of the others arguments.
! 8: * Source code: ext/standard/array.c
! 9: */
! 10:
! 11: /*
! 12: * Test how array_diff() compares indexed arrays containing different
! 13: * data types as values in place of $arr2
! 14: */
! 15:
! 16: echo "*** Testing array_diff() : usage variations ***\n";
! 17:
! 18: // Initialise function arguments not being substituted (if any)
! 19: $array = array(1, 2);
! 20:
! 21: //get an unset variable
! 22: $unset_var = 10;
! 23: unset ($unset_var);
! 24:
! 25: //get heredoc
! 26: $heredoc = <<<END
! 27: This is a heredoc
! 28: END;
! 29:
! 30: //array of values to iterate over
! 31: $values = array(
! 32:
! 33: /*1*/"empty array" => array(),
! 34:
! 35: /*2*/
! 36: "int" => array(
! 37: // int data
! 38: 0,
! 39: 1,
! 40: 12345,
! 41: -2345),
! 42:
! 43: /*3*/
! 44: "float" => array(
! 45: // float data
! 46: 10.5,
! 47: -10.5,
! 48: 12.3456789000e10,
! 49: 12.3456789000E-10,
! 50: .5),
! 51:
! 52: /*4*/
! 53: "null" => array(
! 54: // null data
! 55: NULL,
! 56: null),
! 57:
! 58: /*5*/
! 59: "boolean" => array(
! 60: // boolean data
! 61: true,
! 62: false,
! 63: TRUE,
! 64: FALSE),
! 65:
! 66: /*6*/
! 67: "empty" => array(
! 68: // empty data
! 69: "",
! 70: ''),
! 71:
! 72: /*7*/
! 73: "string" => array(
! 74: // string data
! 75: "string",
! 76: 'string',
! 77: $heredoc),
! 78:
! 79: /*8*/
! 80: "binary" => array(
! 81: // binary data
! 82: b"binary",
! 83: (binary)"binary"),
! 84:
! 85: /*9*/
! 86: "undefined" => array(
! 87: // undefined data
! 88: @$undefined_var),
! 89:
! 90: /*10*/
! 91: "unset" => array(
! 92: // unset data
! 93: @$unset_var)
! 94: );
! 95:
! 96: // loop through each element of the array for $arr2
! 97: $iterator = 1;
! 98: foreach($values as $value) {
! 99: echo "\n Iteration: $iterator \n";
! 100: var_dump( array_diff($array, $value) );
! 101: $iterator++;
! 102: };
! 103:
! 104: echo "Done";
! 105: ?>
! 106: --EXPECTF--
! 107: *** Testing array_diff() : usage variations ***
! 108:
! 109: Iteration: 1
! 110: array(2) {
! 111: [0]=>
! 112: int(1)
! 113: [1]=>
! 114: int(2)
! 115: }
! 116:
! 117: Iteration: 2
! 118: array(1) {
! 119: [1]=>
! 120: int(2)
! 121: }
! 122:
! 123: Iteration: 3
! 124: array(2) {
! 125: [0]=>
! 126: int(1)
! 127: [1]=>
! 128: int(2)
! 129: }
! 130:
! 131: Iteration: 4
! 132: array(2) {
! 133: [0]=>
! 134: int(1)
! 135: [1]=>
! 136: int(2)
! 137: }
! 138:
! 139: Iteration: 5
! 140: array(1) {
! 141: [1]=>
! 142: int(2)
! 143: }
! 144:
! 145: Iteration: 6
! 146: array(2) {
! 147: [0]=>
! 148: int(1)
! 149: [1]=>
! 150: int(2)
! 151: }
! 152:
! 153: Iteration: 7
! 154: array(2) {
! 155: [0]=>
! 156: int(1)
! 157: [1]=>
! 158: int(2)
! 159: }
! 160:
! 161: Iteration: 8
! 162: array(2) {
! 163: [0]=>
! 164: int(1)
! 165: [1]=>
! 166: int(2)
! 167: }
! 168:
! 169: Iteration: 9
! 170: array(2) {
! 171: [0]=>
! 172: int(1)
! 173: [1]=>
! 174: int(2)
! 175: }
! 176:
! 177: Iteration: 10
! 178: array(2) {
! 179: [0]=>
! 180: int(1)
! 181: [1]=>
! 182: int(2)
! 183: }
! 184: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>