note 125012 added to function.array-count-values

From: Date: Fri, 15 May 2020 14:15:22 +0000
Subject: note 125012 added to function.array-count-values
Groups: php.notes 
Request: Send a blank email to php-notes+get-214635@lists.php.net to get a copy of this message
Based on sergolucky96 suggestion Simple way to find number of items with specific *boolean* values in multidimensional array: <?php $list = [ ['id' => 1, 'result' => true], ['id' => 2, 'result' => true], ['id' => 3, 'result' => false], ]; $result = true; echo array_count_values(array_map(function($v) {return $v?'true':'false';},array_column($list, 'result')))[$result] // outputs: 2 ?> ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.195 (proxied: 93.35.241.130) ---- Manual Page -- http://php.net/manual/en/function.array-count-values.php Edit -- https://master.php.net/note/edit/125012 Del: integrated -- https://master.php.net/note/delete/125012/integrated Del: useless -- https://master.php.net/note/delete/125012/useless Del: bad code -- https://master.php.net/note/delete/125012/bad+code Del: spam -- https://master.php.net/note/delete/125012/spam Del: non-english -- https://master.php.net/note/delete/125012/non-english Del: in docs -- https://master.php.net/note/delete/125012/in+docs Del: other reasons-- https://master.php.net/note/delete/125012 Reject -- https://master.php.net/note/reject/125012 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214635) next »