Annotation of embedaddon/php/ext/standard/tests/array/in_array_variation2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test in_array() function : usage variations - different haystack values
        !             3: --FILE--
        !             4: <?php
        !             5: /*
        !             6:  * Prototype  : bool in_array ( mixed $needle, array $haystack [, bool $strict] )
        !             7:  * Description: Searches haystack for needle and returns TRUE  
        !             8:  *              if it is found in the array, FALSE otherwise.
        !             9:  * Source Code: ext/standard/array.c
        !            10: */
        !            11: 
        !            12: /* Test in_array() with different possible haystack values */
        !            13: 
        !            14: echo "*** Testing in_array() with different haystack values ***\n";
        !            15: $misc_array = array (
        !            16:   'a',
        !            17:   'key' =>'d',
        !            18:   3,
        !            19:   ".001" =>-67, 
        !            20:   "-.051" =>"k",
        !            21:   0.091 =>"-.08",
        !            22:   "e" =>"5", 
        !            23:   "y" =>NULL,
        !            24:   NULL =>"",
        !            25:   0,
        !            26:   TRUE,
        !            27:   FALSE,
        !            28:   -27.39999999999,
        !            29:   " ",
        !            30:   "abcd\x00abcd\x00\abcd\x00abcdefghij",
        !            31:   "abcd\nabcd\tabcd\rabcd\0abcd"
        !            32: );
        !            33: $array_type = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, array(), "PHP", "");
        !            34: /* loop to do loose and strict type check of elements in
        !            35:    $array_type on elements in $misc_array using in_array();
        !            36:    checking PHP type comparison tables
        !            37: */
        !            38: $counter = 1;
        !            39: foreach($array_type as $type) {
        !            40:   echo "-- Iteration $counter --\n";
        !            41:   //loose type checking
        !            42:   var_dump( in_array($type,$misc_array ) );  
        !            43:   //strict type checking
        !            44:   var_dump( in_array($type,$misc_array,true) );  
        !            45:   //loose type checking
        !            46:   var_dump( in_array($type,$misc_array,false) );  
        !            47:   $counter++;
        !            48: }
        !            49: 
        !            50: echo "Done\n";
        !            51: ?>
        !            52: --EXPECTF--
        !            53: *** Testing in_array() with different haystack values ***
        !            54: -- Iteration 1 --
        !            55: bool(true)
        !            56: bool(true)
        !            57: bool(true)
        !            58: -- Iteration 2 --
        !            59: bool(true)
        !            60: bool(true)
        !            61: bool(true)
        !            62: -- Iteration 3 --
        !            63: bool(true)
        !            64: bool(false)
        !            65: bool(true)
        !            66: -- Iteration 4 --
        !            67: bool(true)
        !            68: bool(true)
        !            69: bool(true)
        !            70: -- Iteration 5 --
        !            71: bool(true)
        !            72: bool(false)
        !            73: bool(true)
        !            74: -- Iteration 6 --
        !            75: bool(true)
        !            76: bool(false)
        !            77: bool(true)
        !            78: -- Iteration 7 --
        !            79: bool(true)
        !            80: bool(false)
        !            81: bool(true)
        !            82: -- Iteration 8 --
        !            83: bool(true)
        !            84: bool(false)
        !            85: bool(true)
        !            86: -- Iteration 9 --
        !            87: bool(true)
        !            88: bool(true)
        !            89: bool(true)
        !            90: -- Iteration 10 --
        !            91: bool(true)
        !            92: bool(false)
        !            93: bool(true)
        !            94: -- Iteration 11 --
        !            95: bool(true)
        !            96: bool(false)
        !            97: bool(true)
        !            98: -- Iteration 12 --
        !            99: bool(true)
        !           100: bool(true)
        !           101: bool(true)
        !           102: Done

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