1--TEST-- 2Test array_push() function : usage variations - array keys are different data types 3--FILE-- 4<?php 5/* 6 * Pass array_push arrays where the keys are different data types. 7 */ 8 9echo "*** Testing array_push() : usage variations ***\n"; 10 11// Initialise function arguments not being substituted 12$var = 'value'; 13 14//get an unset variable 15$unset_var = 10; 16unset ($unset_var); 17 18// heredoc string 19$heredoc = <<<EOT 20hello world 21EOT; 22 23// arrays of different data types as keys to be passed to $stack argument 24$inputs = array( 25 26 // int data 27/*1*/ 'int' => array( 28 0 => 'zero', 29 1 => 'one', 30 12345 => 'positive', 31 -2345 => 'negative', 32 ), 33 34 // null data 35/*3*/ 'null uppercase' => array( 36 NULL => 'null 1', 37 ), 38 'null lowercase' => array( 39 null => 'null 2', 40 ), 41 42 // boolean data 43/*4*/ 'bool lowercase' => array( 44 true => 'lowert', 45 false => 'lowerf', 46 ), 47 'bool uppercase' => array( 48 TRUE => 'uppert', 49 FALSE => 'upperf', 50 ), 51 52 // empty data 53/*5*/ 'empty double quotes' => array( 54 "" => 'emptyd', 55 ), 56 'empty single quotes' => array( 57 '' => 'emptys', 58 ), 59 60 // string data 61/*6*/ 'string' => array( 62 "stringd" => 'stringd', 63 'strings' => 'strings', 64 $heredoc => 'stringh', 65 ), 66 67 // undefined data 68/*8*/ 'undefined' => array( 69 @$undefined_var => 'undefined', 70 ), 71 72 // unset data 73/*9*/ 'unset' => array( 74 @$unset_var => 'unset', 75 ), 76); 77 78// loop through each sub-array of $inputs to check the behavior of array_push() 79$iterator = 1; 80foreach($inputs as $key => $input) { 81 echo "\n-- Iteration $iterator : $key data --\n"; 82 echo "Before : "; 83 var_dump(count($input)); 84 echo "After : "; 85 var_dump( array_push($input, $var) ); 86 $iterator++; 87}; 88 89echo "Done"; 90?> 91--EXPECT-- 92*** Testing array_push() : usage variations *** 93 94-- Iteration 1 : int data -- 95Before : int(4) 96After : int(5) 97 98-- Iteration 2 : null uppercase data -- 99Before : int(1) 100After : int(2) 101 102-- Iteration 3 : null lowercase data -- 103Before : int(1) 104After : int(2) 105 106-- Iteration 4 : bool lowercase data -- 107Before : int(2) 108After : int(3) 109 110-- Iteration 5 : bool uppercase data -- 111Before : int(2) 112After : int(3) 113 114-- Iteration 6 : empty double quotes data -- 115Before : int(1) 116After : int(2) 117 118-- Iteration 7 : empty single quotes data -- 119Before : int(1) 120After : int(2) 121 122-- Iteration 8 : string data -- 123Before : int(3) 124After : int(4) 125 126-- Iteration 9 : undefined data -- 127Before : int(1) 128After : int(2) 129 130-- Iteration 10 : unset data -- 131Before : int(1) 132After : int(2) 133Done 134