Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_assoc_variation9.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test array_intersect_assoc() function : usage variations - two dimensional arrays for $arr1 and $arr2 arguments 
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_intersect_assoc(array $arr1, array $arr2 [, array $...])
                      6:  * Description: Returns the entries of arr1 that have values which are present in all the other arguments.
                      7:  * Keys are used to do more restrictive check
                      8:  * Source code: ext/standard/array.c
                      9: */
                     10: 
                     11: /*
                     12: * Testing the behavior of array_intersect_assoc() by passing 2-D arrays
                     13: * to both $arr1 and $arr2 argument. 
                     14: * Optional argument takes the same value as that of $arr1
                     15: */
                     16: 
                     17: echo "*** Testing array_intersect_assoc() : passing two dimensional array to both \$arr1 and \$arr2 arguments ***\n";
                     18: 
                     19: // two dimensional arrays for $arr1 and $arr2 argument
                     20: $arr1 = array (
                     21:   
                     22:   // arrays with default keys
                     23:   array(1, 2, "hello", 'world'),
                     24:   array(1, 2, 3, 4),
                     25: 
                     26:   // arrays with explicit keys
                     27:   array(1 => "one", 2 => "two", 3 => "three"),
                     28:   array("ten" => 10, "twenty" => 20.00, "thirty" => 30)
                     29: );  
                     30: 
                     31: $arr2 = array (
                     32:   array(1, 2, 3, 4),
                     33:   array(1 => "one", 2 => "two", 3 => "three")
                     34: );
                     35: 
                     36: /* Passing the entire array as argument to $arr1 and $arr2 */
                     37: // Calling array_intersect_assoc() with default arguments
                     38: echo "-- Passing the entire 2-D array to \$arr1 and \$arr2 --\n";
                     39: echo "- With default arguments -\n";
                     40: var_dump( array_intersect_assoc($arr1, $arr2) );
                     41: 
                     42: // Calling array_intersect_assoc() with more arguments
                     43: // additional argument passed is the same as $arr1
                     44: echo "- With more arguments -\n";
                     45: var_dump( array_intersect_assoc($arr1, $arr2, $arr1) );
                     46: 
                     47: /* Passing the sub-array as argument to $arr1 and $arr2 */
                     48: // Calling array_intersect_assoc() with default arguments
                     49: echo "-- Passing the sub-array to \$arr1 and \$arr2 --\n";
                     50: echo "- With default arguments -\n";
                     51: var_dump( array_intersect_assoc($arr1[0], $arr2[0]) );
                     52: 
                     53: // Calling array_intersect_assoc() with more arguments
                     54: // additional argument passed is the same as $arr1
                     55: echo "- With more arguments -\n";
                     56: var_dump( array_intersect_assoc($arr1[0], $arr2[0], $arr1[0]) );
                     57: 
                     58: echo "Done";
                     59: ?>
                     60: --EXPECTF--
                     61: *** Testing array_intersect_assoc() : passing two dimensional array to both $arr1 and $arr2 arguments ***
                     62: -- Passing the entire 2-D array to $arr1 and $arr2 --
                     63: - With default arguments -
                     64: array(2) {
                     65:   [0]=>
                     66:   array(4) {
                     67:     [0]=>
                     68:     int(1)
                     69:     [1]=>
                     70:     int(2)
                     71:     [2]=>
                     72:     string(5) "hello"
                     73:     [3]=>
                     74:     string(5) "world"
                     75:   }
                     76:   [1]=>
                     77:   array(4) {
                     78:     [0]=>
                     79:     int(1)
                     80:     [1]=>
                     81:     int(2)
                     82:     [2]=>
                     83:     int(3)
                     84:     [3]=>
                     85:     int(4)
                     86:   }
                     87: }
                     88: - With more arguments -
                     89: array(2) {
                     90:   [0]=>
                     91:   array(4) {
                     92:     [0]=>
                     93:     int(1)
                     94:     [1]=>
                     95:     int(2)
                     96:     [2]=>
                     97:     string(5) "hello"
                     98:     [3]=>
                     99:     string(5) "world"
                    100:   }
                    101:   [1]=>
                    102:   array(4) {
                    103:     [0]=>
                    104:     int(1)
                    105:     [1]=>
                    106:     int(2)
                    107:     [2]=>
                    108:     int(3)
                    109:     [3]=>
                    110:     int(4)
                    111:   }
                    112: }
                    113: -- Passing the sub-array to $arr1 and $arr2 --
                    114: - With default arguments -
                    115: array(2) {
                    116:   [0]=>
                    117:   int(1)
                    118:   [1]=>
                    119:   int(2)
                    120: }
                    121: - With more arguments -
                    122: array(2) {
                    123:   [0]=>
                    124:   int(1)
                    125:   [1]=>
                    126:   int(2)
                    127: }
                    128: Done

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