blob: b125ac9281a98308e19f1244ec9e226b7c67b7ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
--TEST--
Test array_filter() function : usage variations - 'input' array containing references
--FILE--
<?php
/*
* Passing 'input' array which contains elements as reference to other data
*/
echo "*** Testing array_filter() : usage variations - 'input' containing references ***\n";
function callback($input)
{
if($input > 5) {
return true;
}
else {
return false;
}
}
// initializing variables
$value1 = array(1, 2, 8);
$value2 = array(5, 6, 4);
$input = array(&$value1, 10, &$value2, 'value');
// with 'callback' argument
var_dump( array_filter($input, 'callback') );
// with default 'callback' argument
var_dump( array_filter($input) );
echo "Done"
?>
--EXPECT--
*** Testing array_filter() : usage variations - 'input' containing references ***
array(3) {
[0]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(8)
}
[1]=>
int(10)
[2]=>
&array(3) {
[0]=>
int(5)
[1]=>
int(6)
[2]=>
int(4)
}
}
array(4) {
[0]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(8)
}
[1]=>
int(10)
[2]=>
&array(3) {
[0]=>
int(5)
[1]=>
int(6)
[2]=>
int(4)
}
[3]=>
string(5) "value"
}
Done
|