Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P6435
php foreach vs array_filter
Active
Public
Actions
Authored by
dcausse
on Dec 6 2017, 2:03 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F11220993: php foreach vs array_filter
Dec 6 2017, 2:03 PM
2017-12-06 14:03:03 (UTC+0)
Subscribers
None
$namespaces
=
array_filter
(
$namespaces
,
function
(
$k
,
$v
)
{
wfDebug
(
"via array_filter: "
.
gettype
(
$v
)
.
" : "
.
gettype
(
NS_MAIN
)
);
return
true
;
// $v !== NS_MAIN;
},
ARRAY_FILTER_USE_BOTH
);
wfDebug
(
"VIA reset: "
.
gettype
(
reset
(
$namespaces
)
)
);
wfDebug
(
"DUMP:"
.
print_r
(
$namespaces
,
true
)
);
foreach
(
$namespaces
as
$k
=>
$v
)
{
wfDebug
(
"$k => $v | "
.
NS_MAIN
);
wfDebug
(
"via foreach:"
.
gettype
(
$v
)
.
" : "
.
gettype
(
NS_MAIN
)
);
if
(
$v
===
NS_MAIN
)
{
wfDebug
(
"UNSET"
.
print_r
(
$namespaces
,
true
)
);
unset
(
$namespaces
[
$k
]
);
}
}
wfDebug
(
print_r
(
$namespaces
,
true
)
);
will
output
:
2017
-
12
-
06
13
:
59
:
20
cirrustestwiki
wfDebug
DEBUG
:
via
array_filter
:
integer
:
integer
2017
-
12
-
06
13
:
59
:
20
cirrustestwiki
wfDebug
DEBUG
:
VIA
reset
:
string
2017
-
12
-
06
13
:
59
:
20
cirrustestwiki
wfDebug
DEBUG
:
DUMP
:
Array
(
[
0
]
=>
0
)
2017
-
12
-
06
13
:
59
:
20
cirrustestwiki
wfDebug
DEBUG
:
0
=>
0
|
0
2017
-
12
-
06
13
:
59
:
20
cirrustestwiki
wfDebug
DEBUG
:
via
foreach
:
string
:
integer
2017
-
12
-
06
13
:
59
:
20
cirrustestwiki
wfDebug
DEBUG
:
Array
(
[
0
]
=>
0
)
Event Timeline
dcausse
created this paste.
Dec 6 2017, 2:03 PM
2017-12-06 14:03:03 (UTC+0)
Log In to Comment