Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86741 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59418 invoked from network); 18 Jun 2015 01:40:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2015 01:40:55 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wg0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:33064] helo=mail-wg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/D1-46946-6A122855 for ; Wed, 17 Jun 2015 21:40:55 -0400 Received: by wgez8 with SMTP id z8so50829380wge.0 for ; Wed, 17 Jun 2015 18:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=eNG4qkc1SBVelfgOeHsSIY5SSPK0FJO+hF6XUJOw7y0=; b=SjeFja4PV+QIBpiHgYao4jFebt/p8/JqijUot5AbZn0srcPVCtgUezOIIG1dgpEu7d HaSfAlALlYPYAtMF3MnmcchSja+Wnm32FEYlDzdkTESjNG8NaTe+u3G+jyXGzNstSo9y +XMwIcJTnXE4i8hl7VodkQN+ERqctIIJCs159UgoyNwxr1ObtaL9jLpiGk6h+OL1QcGE reVDTsbryrtNwDuKyapNs3MG5IiX3L4eZpuMNLBsr5eaVM33Qm7h5Sq4t/Ti+stAG3Kq uksl8Evz79Eton2Yn/vwIgQx4UZfnrsolmBV+2hLE9h8nXrqX9OjLoeMbe4lyxFdMM6L /puA== MIME-Version: 1.0 X-Received: by 10.194.63.228 with SMTP id j4mr11125381wjs.38.1434591651908; Wed, 17 Jun 2015 18:40:51 -0700 (PDT) Received: by 10.28.169.130 with HTTP; Wed, 17 Jun 2015 18:40:51 -0700 (PDT) Received: by 10.28.169.130 with HTTP; Wed, 17 Jun 2015 18:40:51 -0700 (PDT) In-Reply-To: References: Date: Wed, 17 Jun 2015 19:40:51 -0600 Message-ID: To: Netroby Cc: PHP Internals Content-Type: multipart/alternative; boundary=047d7ba97f3acf51680518c0e50d Subject: Re: [PHP-DEV] The most efficicient way to pick key,value from a large array From: derokorian@gmail.com (Ryan Pallas) --047d7ba97f3acf51680518c0e50d Content-Type: text/plain; charset=UTF-8 Use array_intersect_key with array_flip. $pending_pick_key1 = [uid, username]; array_intersect_key($origin_array, array_flip( $pending_pick_key1)); On Jun 17, 2015 7:25 PM, "Netroby" wrote: > Now, we have a large array, contains user profile. > [uid, username, password, email, qq, msn, skype, address, zipcode, > telphone, mobile.......] > > We need to pick information from this big array, and we know the key > we want to pick. > What's the efficient way ? Is there any function like > > $pending_pick_key1 = [uid, username]; > array_pick($origin_array, $pending_pick_key1); //return array > contains [uid, username] > > $pending_pick_key2 = [username, password]; > array_pick($origin_array, $pending_pick_key2); //return array contains > [username, password] > > > we current using array_filter and pass function into it to do this job. > But it's not fast as we test. > > Any other ideas beside array_filter? > > Or we have to implement an php extension to do this job ? > > Sorry for trouble you. need your help. > > > Appreciate your time. > ---------------------------- > Netroby > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --047d7ba97f3acf51680518c0e50d--