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

1.1       misho       1: --TEST--
                      2: Test array_intersect_assoc() function : basic functionality 
                      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 different arrays for the arguments.
                     13: * Function is tested by passing associative array as well as array with default keys.
                     14: */
                     15: 
                     16: echo "*** Testing array_intersect_assoc() : basic functionality ***\n";
                     17: 
                     18: // array with default keys
                     19: $arr_default_keys = array(1, 2, "hello", 'world');
                     20: 
                     21: // associative array
                     22: $arr_associative = array("one" => 1, "two" => 2);
                     23: 
                     24: // default key array for both $arr1 and $arr2 argument
                     25: var_dump( array_intersect_assoc($arr_default_keys, $arr_default_keys) );
                     26: 
                     27: // default key array for $arr1 and associative array for $arr2 argument
                     28: var_dump( array_intersect_assoc($arr_default_keys, $arr_associative) );
                     29: 
                     30: // associative array for $arr1 and default key array for $arr2
                     31: var_dump( array_intersect_assoc($arr_associative, $arr_default_keys) );
                     32: 
                     33: // associative array for both $arr1 and $arr2 argument
                     34: var_dump( array_intersect_assoc($arr_associative, $arr_associative) );
                     35: 
                     36: // more arrays to be intersected
                     37: $arr3 = array(2, 3, 4);
                     38: var_dump( array_intersect_assoc($arr_default_keys, $arr_associative, $arr3) );
                     39: var_dump( array_intersect_assoc($arr_associative, $arr_default_keys, $arr3, $arr_associative) );
                     40: 
                     41: echo "Done";
                     42: ?>
                     43: --EXPECTF--
                     44: *** Testing array_intersect_assoc() : basic functionality ***
                     45: array(4) {
                     46:   [0]=>
                     47:   int(1)
                     48:   [1]=>
                     49:   int(2)
                     50:   [2]=>
                     51:   string(5) "hello"
                     52:   [3]=>
                     53:   string(5) "world"
                     54: }
                     55: array(0) {
                     56: }
                     57: array(0) {
                     58: }
                     59: array(2) {
                     60:   ["one"]=>
                     61:   int(1)
                     62:   ["two"]=>
                     63:   int(2)
                     64: }
                     65: array(0) {
                     66: }
                     67: array(0) {
                     68: }
                     69: Done

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