2
Test array_unique() function : usage variations - associative array with different keys
5
/* Prototype : array array_unique(array $input)
6
* Description: Removes duplicate values from array
7
* Source code: ext/standard/array.c
11
* Testing the functionality of array_unique() by passing different
12
* associative arrays having different keys to $input argument.
15
echo "*** Testing array_unique() : assoc. array with diff. keys passed to \$input argument ***\n";
17
// get an unset variable
21
// get a resource variable
22
$fp = fopen(__FILE__, "r");
27
public function __toString(){
28
return "Class A object";
32
// get a heredoc string
37
// different associative arrays to be passed to $input argument
39
/*1*/ // arrays with integer keys
40
array(0 => "0", 1 => "0"),
41
array(1 => "1", 2 => "2", 3 => 1, 4 => "4"),
43
// arrays with float keys
44
/*3*/ array(2.3333 => "float", 44.44 => "float"),
45
array(1.2 => "f1", 3.33 => "f2", 4.89999922839999 => "f1", 3333333.333333 => "f4"),
47
// arrays with string keys
48
/*5*/ array('\tHello' => 111, 're\td' => "color", '\v\fworld' => 2.2, 'pen\n' => 111),
49
array("\tHello" => 111, "re\td" => "color", "\v\fworld" => 2.2, "pen\n" => 111),
50
array("hello", $heredoc => "string", "string"),
52
// array with object, unset variable and resource variable
53
/*8*/ array(new classA() => 11, @$unset_var => "hello", $fp => 'resource', 11, "hello"),
56
// loop through each sub-array of $inputs to check the behavior of array_unique()
58
foreach($inputs as $input) {
59
echo "-- Iteration $iterator --\n";
60
var_dump( array_unique($input) );
69
*** Testing array_unique() : assoc. array with diff. keys passed to $input argument ***
71
Warning: Illegal offset type in %s on line %d
73
Warning: Illegal offset type in %s on line %d