Re: The most efficicient way to pick key,value from a large array

From: Date: Thu, 18 Jun 2015 01:40:51 +0000
Subject: Re: The most efficicient way to pick key,value from a large array
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-86741@lists.php.net to get a copy of this message
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" <hufeng1987@gmail.com> 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 > >

« previous php.internals (#86741) next »