note 119998 deleted from function.array-filter by cmb

From: Date: Fri, 07 Oct 2016 14:52:15 +0000
Subject: note 119998 deleted from function.array-filter by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206798@lists.php.net to get a copy of this message
Note Submitter: ohcc at 163 dot com ---- 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>'; ?>

« previous php.notes (#206798) next »