Dave tại SymmetricDesigns Dot Com ¶ ¶
14 năm trước
Another example of something to watch out for when using references with arrays. It seems that even an usused reference to an array cell modifies the *source* of the reference. Strange behavior for an assignment statement [is this why I've seen it written as an =& operator? - although this doesn't happen with regular variables].
Produces:
Array
[
[0] => 1
[1] => 22 // var_dump[] will show the & here
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
Produces:
Array
[
[0] => 1
[1] => 2
]
Ivan tại mailinator dot com ¶
13 năm trước
A little gotcha [be careful with references!]:
Output:
Array
[
[a] => first
[b] => second
[c] => second
]
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
Array
[
[a] => first
[b] => second
[c] => third
]
Carlos ¶ ¶
17 năm trước
in the example below, you would get the same result if you change the function to something like:
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
0
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
1
Produces:
Array
[
[0] => 1
[1] => 2
]
gnuffo1 tại gmail dot com ¶
12 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
3
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
4
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
5
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
6
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
7
Produces:
Array
[
[0] => 1
[1] => 2
]
midir ¶ ¶
13 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
9
Produces:
Array
[
[0] => 1
[1] => 2
]
0
1
Carlos ¶ ¶
17 năm trước
3
4
5
6
gnuffo1 tại gmail dot com ¶
12 năm trước
8
9
A little gotcha [be careful with references!]:
0
A little gotcha [be careful with references!]:
1midir ¶ ¶
17 năm trước
A little gotcha [be careful with references!]:
2
A little gotcha [be careful with references!]:
3
A little gotcha [be careful with references!]:
4
gnuffo1 tại gmail dot com ¶
14 năm trước
A little gotcha [be careful with references!]:
6
A little gotcha [be careful with references!]:
7
A little gotcha [be careful with references!]:
8
A little gotcha [be careful with references!]:
9
0
Output:
12 năm trước ¶
14 năm trước
2
Output:
3
Output:
4
Output:
5
Output:
midir ¶ ¶
14 năm trước
7
Output:
8
Output:
9
Output:
Array
0
[
[a] => first
[b] => second
[c] => second
]
Array
1
[
[a] => first
[b] => second
[c] => second
]
Array
2
[
[a] => first
[b] => second
[c] => second
]
Iryoku tại Terra Dot es ¶ ¶
18 năm trước
Array
4
[
[a] => first
[b] => second
[c] => second
]
Array
5
[
[a] => first
[b] => second
[c] => second
]
Array
6
[
[a] => first
[b] => second
[c] => second
]
Array
7
[
[a] => first
[b] => second
[c] => second
]
Array
[
[a] => first
[b] => second
[c] => second
]
8Alexander tại Gamerev Dot org ¶ ¶
17 năm trước
Array
9
[
[a] => first
[b] => second
[c] => second
]
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
0
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
1
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
2
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
3gnuffo1 tại gmail dot com ¶
17 năm trước
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
4
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
5
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
6
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
7
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
8
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
9
Array
0
[
[a] => first
[b] => second
[c] => third
]
gnuffo1 tại gmail dot com ¶
17 năm trước
Array
2
[
[a] => first
[b] => second
[c] => third
]
Array
3
[
[a] => first
[b] => second
[c] => third
]
gnuffo1 tại gmail dot com ¶
14 năm trước
Array
5
[
[a] => first
[b] => second
[c] => third
]
Array
6
[
[a] => first
[b] => second
[c] => third
]
Array
7
[
[a] => first
[b] => second
[c] => third
]
Array
8
[
[a] => first
[b] => second
[c] => third
]
Array
9
[
[a] => first
[b] => second
[c] => third
]
0
12 năm trước ¶
midir ¶
2
3
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
1
5
6Iryoku tại Terra Dot es ¶ ¶
18 năm trước
7
8
9
Alexander tại Gamerev Dot org ¶ ¶
8 năm trước
Another example of something to watch out for when using references with arrays. It seems that even an usused reference to an array cell modifies the *source* of the reference. Strange behavior for an assignment statement [is this why I've seen it written as an =& operator? - although this doesn't happen with regular variables].
Produces:
Array
[
[0] => 1
[1] => 22 // var_dump[] will show the & here
]
in the example below, you would get the same result if you change the function to something like:
2
in the example below, you would get the same result if you change the function to something like:
3
in the example below, you would get the same result if you change the function to something like:
4
in the example below, you would get the same result if you change the function to something like:
5
in the example below, you would get the same result if you change the function to something like:
6
Iryoku tại Terra Dot es ¶ ¶
midir ¶
in the example below, you would get the same result if you change the function to something like:
8
in the example below, you would get the same result if you change the function to something like:
9
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
00
Produces:
Array
[
[0] => 1
[1] => 2
]
Iryoku tại Terra Dot es ¶ ¶
18 năm trước
Alexander tại Gamerev Dot org ¶
8 năm trước ¶
18 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
03
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
04
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
05
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
06
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
07
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
08
Produces:
Array
[
[0] => 1
[1] => 2
]
Alexander tại Gamerev Dot org ¶ ¶
18 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
10
Produces:
Array
[
[0] => 1
[1] => 2
]
Alexander tại Gamerev Dot org ¶ ¶
8 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
11
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
12
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
13
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
14
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
15
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
16
Produces:
Array
[
[0] => 1
[1] => 2
]
Nathan ¶ ¶
12 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
18
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
19
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
20
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
21
Produces:
Array
[
[0] => 1
[1] => 2
]
midir ¶ ¶
14 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
23
Produces:
Array
[
[0] => 1
[1] => 2
]
Iryoku tại Terra Dot es ¶ ¶
12 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
24
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
25
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
26
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
Produces:
Array
[
[0] => 1
[1] => 2
]
27midir ¶ ¶
17 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
28
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
29
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
30
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
31
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
32
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
33
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
34
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
35
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
36
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
37
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
38
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
39
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
40
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
41
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
42
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
43
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
44
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
45
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
46
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
47
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
48
Produces:
Array
[
[0] => 1
[1] => 2
]
Iryoku tại Terra Dot es ¶ ¶
17 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
50
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
51
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
52
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
53
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
54
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
55
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
56
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
57
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
58
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
59
Produces:
Array
[
[0] => 1
[1] => 2
]
gnuffo1 tại gmail dot com ¶
12 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
61
Produces:
Array
[
[0] => 1
[1] => 2
]
Array
7
[
[a] => first
[b] => second
[c] => second
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
Produces:
Array
[
[0] => 1
[1] => 2
]
63midir ¶ ¶
17 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
64
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
65
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
66
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
67
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
Produces:
Array
[
[0] => 1
[1] => 2
]
68Iryoku tại Terra Dot es ¶ ¶
18 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
69
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
70
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
71
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
Produces:
Array
[
[0] => 1
[1] => 2
]
72Alexander tại Gamerev Dot org ¶ ¶
17 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
73
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
74
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
75
Produces:
Array
[
[0] => 1
[1] => 2
]
Add 'unset[$a]' between the foreachs to obtain the 'correct' output:
1
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
77
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
Produces:
Array
[
[0] => 1
[1] => 2
]
788 năm trước ¶
8 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
79
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
80
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
81
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
Produces:
Array
[
[0] => 1
[1] => 2
]
82Nathan ¶ ¶
14 năm trước
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
83
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
84
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
85
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
86
Produces:
Array
[
[0] => 1
[1] => 2
]
I fixed my bug by rewriting the code without references, but it can also be fixed with the unset[] function:
87
Produces:
Array
[
[0] => 1
[1] => 2
]