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

1.1       misho       1: --TEST--
                      2: Test array_intersect_key() function : usage variation - Passing integer indexed array
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_intersect_key(array arr1, array arr2 [, array ...])
                      6:  * Description: Returns the entries of arr1 that have keys which are present in all the other arguments. 
                      7:  * Source code: ext/standard/array.c
                      8:  */
                      9: 
                     10: echo "*** Testing array_intersect_key() : usage variation ***\n";
                     11: 
                     12: // Initialise function arguments not being substituted (if any)
                     13: $input_array = array(0 => '0', -1 => '-1' , 02 => 'two', -07 => '-07', 0xA => '0xA', -0xC => '-0xc'); 
                     14: 
                     15: $input_arrays = array(
                     16:       'decimal indexed' => array(10 => '10', '-17' => '-17'),
                     17:       'octal indexed' => array(-011 => '-011', 012 => '012'),
                     18:       'hexa  indexed' => array(0x12 => '0x12', -0x7 => '-0x7', ),
                     19: );
                     20: 
                     21: foreach($input_arrays as $key =>$value) {
                     22:       echo "\n--$key--\n";
                     23:       var_dump( array_intersect_key($input_array, $value) );
                     24:       var_dump( array_intersect_key($value,$input_array ) );
                     25: }
                     26: ?>
                     27: ===DONE===
                     28: --EXPECTF--
                     29: *** Testing array_intersect_key() : usage variation ***
                     30: 
                     31: --decimal indexed--
                     32: array(1) {
                     33:   [10]=>
                     34:   string(3) "0xA"
                     35: }
                     36: array(1) {
                     37:   [10]=>
                     38:   string(2) "10"
                     39: }
                     40: 
                     41: --octal indexed--
                     42: array(1) {
                     43:   [10]=>
                     44:   string(3) "0xA"
                     45: }
                     46: array(1) {
                     47:   [10]=>
                     48:   string(3) "012"
                     49: }
                     50: 
                     51: --hexa  indexed--
                     52: array(1) {
                     53:   [-7]=>
                     54:   string(3) "-07"
                     55: }
                     56: array(1) {
                     57:   [-7]=>
                     58:   string(4) "-0x7"
                     59: }
                     60: ===DONE===

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