Annotation of embedaddon/php/ext/standard/tests/array/array_flip_basic.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_flip() function : basic functionality
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : array array_flip(array $input)
! 6: * Description: Return array with key <-> value flipped
! 7: * Source code: ext/standard/array.c
! 8: */
! 9:
! 10: echo "*** Testing array_flip() : basic functionality ***\n";
! 11:
! 12: // array with default keys - numeric values
! 13: $input = array(1, 2);
! 14: var_dump( array_flip($input) );
! 15:
! 16: // array with default keys - string values
! 17: $input = array('value1', "value2");
! 18: var_dump( array_flip($input) );
! 19:
! 20: // associative arrays - key as string
! 21: $input = array('key1' => 1, "key2" => 2);
! 22: var_dump( array_flip($input) );
! 23:
! 24: // associative arrays - key as numeric
! 25: $input = array(1 => 'one', 2 => "two");
! 26: var_dump( array_flip($input) );
! 27:
! 28: // combination of associative and non-associative array
! 29: $input = array(1 => 'one','two', 3 => 'three', 4, "five" => 5);
! 30: var_dump( array_flip($input) );
! 31: echo "Done"
! 32: ?>
! 33: --EXPECTF--
! 34: *** Testing array_flip() : basic functionality ***
! 35: array(2) {
! 36: [1]=>
! 37: int(0)
! 38: [2]=>
! 39: int(1)
! 40: }
! 41: array(2) {
! 42: ["value1"]=>
! 43: int(0)
! 44: ["value2"]=>
! 45: int(1)
! 46: }
! 47: array(2) {
! 48: [1]=>
! 49: string(4) "key1"
! 50: [2]=>
! 51: string(4) "key2"
! 52: }
! 53: array(2) {
! 54: ["one"]=>
! 55: int(1)
! 56: ["two"]=>
! 57: int(2)
! 58: }
! 59: array(5) {
! 60: ["one"]=>
! 61: int(1)
! 62: ["two"]=>
! 63: int(2)
! 64: ["three"]=>
! 65: int(3)
! 66: [4]=>
! 67: int(4)
! 68: [5]=>
! 69: string(4) "five"
! 70: }
! 71: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>