Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F11220993
php foreach vs array_filter
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
dcausse
Dec 6 2017, 2:03 PM
2017-12-06 14:03:03 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
php foreach vs array_filter
View Options
$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
)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5166405
Default Alt Text
php foreach vs array_filter (1 KB)
Attached To
Mode
P6435 php foreach vs array_filter
Attached
Detach File
Event Timeline
Log In to Comment