Re: multi dimensional array question

From: Date: Sat, 01 May 2010 19:59:36 +0000
Subject: Re: multi dimensional array question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-304827@lists.php.net to get a copy of this message
On 30 April 2010 23:57, Nick Balestra <nick@beyounic.com> wrote: > us_census = array('NY' => array('New York' => 8008278), >                                   'CA' => array('Los > Angeles' => 3694820, >                                                                 > 'San Diego' => 1223400), >                                   'IL' => > array('Chicago' => 2896016), >                                   'TX' => > array('Houston' => 1953631, >                                                                 > 'Dallas' => 1188580, >                                                                 > 'San Antonio' => 1144646), >                                   'PA' => > array('Philadelphia' => 1517550), >                                   'AZ' => > array('Phoenix' => 1321045), >                                   'MI' => > array('Detroit' => 951270)); <?php $us_census = array ( ... ); function Sum($a, $b) { return $a + (is_array($b) ? array_reduce($b, 'Sum') : $b); } echo array_reduce($us_census, 'Sum'); ?> outputs ... 23899236 -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling

« previous php.general (#304827) next »