note 119998 added to function.array-filter

From: Date: Fri, 07 Oct 2016 08:49:28 +0000
Subject: note 119998 added to function.array-filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-206787@lists.php.net to get a copy of this message
Pass ARRAY_FILTER_USE_BOTH to array_filter() as the third parameter if you want to use both key and value in the callback function. The first parameter passed to the callback function is treated as value, while the second as key. Here's an example. <?php $data = array( 'domain' => 'wuxiancheng.cn', 'ip' => '10.10.10.10' ); $dataFiltered = array_filter( $data, function($value, $key){ return strlen($key) > 2; }, ARRAY_FILTER_USE_BOTH ); echo '<pre>'; print_r($dataFiltered); echo '</pre>'; ?> ---- Server IP: 72.52.91.14 Probable Submitter: 118.117.77.84 ---- Manual Page -- http://php.net/manual/en/function.array-filter.php Edit -- https://master.php.net/note/edit/119998 Del: integrated -- https://master.php.net/note/delete/119998/integrated Del: useless -- https://master.php.net/note/delete/119998/useless Del: bad code -- https://master.php.net/note/delete/119998/bad+code Del: spam -- https://master.php.net/note/delete/119998/spam Del: non-english -- https://master.php.net/note/delete/119998/non-english Del: in docs -- https://master.php.net/note/delete/119998/in+docs Del: other reasons-- https://master.php.net/note/delete/119998 Reject -- https://master.php.net/note/reject/119998 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206787) next »