import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / 005.php
blobff6881e7d57894e95a9525f8a09f0f45902a3251
1 <?php
2 /* Prototype: mixed array_shift( array &array );
3 * Description: Shifts the first value of the array off and returns it.
4 */
6 array_shift($GLOBALS);
8 $empty_array = array();
9 $number = 5;
10 $str = "abc";
13 /* Various combinations of arrays to be used for the test */
14 $mixed_array = array(
15 array(),
16 array( 1,2,3,4,5,6,7,8,9 ),
17 array( "One", "_Two", "Three", "Four", "Five" ),
18 array( 6, "six", 7, "seven", 8, "eight", 9, "nine" ),
19 array( "a" => "aaa", "A" => "AAA", "c" => "ccc", "d" => "ddd", "e" => "eee" ),
20 array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
21 array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
22 array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF",
23 "blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
24 array( 12, "name", 'age', '45' ),
25 array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
26 array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
27 5.4 => 54, 5.7 => 57, "5.4" => 554, "5.7" => 557 )
30 /* Testing Error Conditions */
31 echo "\n*** Testing Error Conditions ***\n";
33 /* Zero argument */
34 var_dump( array_shift() );
36 /* Scalar argument */
37 var_dump( array_shift($number) );
39 /* String argument */
40 var_dump( array_shift($str) );
42 /* Invalid Number of arguments */
43 var_dump( array_shift($mixed_array[1],$mixed_array[2]) );
45 /* Empty Array as argument */
46 var_dump( array_shift($empty_array) );
48 /* Loop to test normal functionality with different arrays inputs */
49 echo "\n*** Testing with various array inputs ***\n";
51 $counter = 1;
52 foreach( $mixed_array as $sub_array ) {
53 echo "\n-- Input Array for Iteration $counter is -- \n";
54 print_r( $sub_array );
55 echo "\nOutput after shift is :\n";
56 var_dump( array_shift($sub_array) );
57 $counter++;
60 /*Checking for internal array pointer beint reset when shift is called */
62 echo"\n*** Checking for internal array pointer being reset when shift is called ***\n";
64 echo "\nCurrent Element is : ";
65 var_dump( current($mixed_array[1]) );
67 echo "\nNext Element is : ";
68 var_dump( next($mixed_array[1]) );
70 echo "\nNext Element is : ";
71 var_dump( next($mixed_array[1]) );
73 echo "\nshifted Element is : ";
74 var_dump( array_shift($mixed_array[1]) );
76 echo "\nCurrent Element after shift operation is: ";
77 var_dump( current($mixed_array[1]) );
79 echo"Done";