Newsgroups: php.internals,php.qa Path: news.php.net Xref: news.php.net php.internals:63251 php.qa:66727 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69831 invoked from network); 30 Sep 2012 12:05:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Sep 2012 12:05:40 -0000 Authentication-Results: pb1.pair.com header.from=kuldeepdhaka9@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kuldeepdhaka9@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.42 as permitted sender) X-PHP-List-Original-Sender: kuldeepdhaka9@gmail.com X-Host-Fingerprint: 74.125.83.42 mail-ee0-f42.google.com Received: from [74.125.83.42] ([74.125.83.42:44754] helo=mail-ee0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/87-13052-39538605 for ; Sun, 30 Sep 2012 08:05:39 -0400 Received: by eeil10 with SMTP id l10so1976193eei.29 for ; Sun, 30 Sep 2012 05:05:36 -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=emVWdeb+fZhimbErGDjuUg2AFT1GjfMnlphWCmo/WDk=; b=if2bEW2yx3bKxNGtr9rPmdDH/LiKoCc4FSRjKNZemYXGgz5N02NwasL/UrptiFjdQt Z+dGelXnaA/b8RvDfaZbZz1JC/xF9+90Bnaq1HA6lPvHQJMREaNNG/Fr5EmpsSB4V2FC Pa2jOAgImIHjG3xoo6cyj3fIkKy/MONq5W+tRby/PmM2Ylz0IussWAhe9TBSRLLXp92x io/YbT9o7dS/PphEPZ3/07j+9FxSISMiR7cQtGqt0v0FCpRUqqEldO7WSCDNJJNdBlPX ENWSR84kKaM58vwMReE79oUZ5wDarq49mg2ZfTnH6aZ8EtxsmdIOK2DRuh5CjbSCJhci Fwgg== MIME-Version: 1.0 Received: by 10.14.173.9 with SMTP id u9mr14841340eel.8.1349006736267; Sun, 30 Sep 2012 05:05:36 -0700 (PDT) Received: by 10.14.97.78 with HTTP; Sun, 30 Sep 2012 05:05:36 -0700 (PDT) In-Reply-To: <781C00C3309B4CAFB5E4B612E94A46C1@charliesomerville.com> References: <781C00C3309B4CAFB5E4B612E94A46C1@charliesomerville.com> Date: Sun, 30 Sep 2012 17:35:36 +0530 Message-ID: To: Charlie Somerville Cc: Ferenc Kovacs , php-qa@lists.php.net, PHP Internals Content-Type: multipart/alternative; boundary=047d7b603d725099ba04caea1b3e Subject: Re: [PHP-DEV] Funny array function From: kuldeepdhaka9@gmail.com (kuldeep dhaka) --047d7b603d725099ba04caea1b3e Content-Type: text/plain; charset=ISO-8859-1 i m extending the wordpress internal widget input api to simplify things, so for that i wanted a function that perform drill. i have considered other options but they wont be effecient, if a php internal function is build it would be just a [] similar one, and most effecient because while recursing through the function. i built a drill function function array_drill( $array, $key){ foreach( $key as $k ){ if( isset( $array[$k] ) ) $array = $array[$k]; else return false; } return $array; } just convert [] to function drill On Sun, Sep 30, 2012 at 5:26 PM, Charlie Somerville < charlie@charliesomerville.com> wrote: > I'm struggling to imagine how such a function would be useful considering > you can already use [] to index arrays. > > If you have a variable 'depth' you need to drill down to, then writing a > function to do that is also fairly trivial. > > On Sunday, 30 September 2012 at 9:50 PM, kuldeep dhaka wrote: > > hello guys, > this is my first time, if thing mail is at wrong place please forward it > the right place. > while coding , i just found a requirement, its little bit funny. if it > already exists, please be calm and mail me the function name and its usage. > > for accessing arrays we use > echo $array["school"]["class"]["roll_number"]["name"]; // this will print > the name of the student > /* > i was thinking if is their any function that can do the above work like > */ > echo array_drill($array, array("school","class","roll_number","name")); > > // like wise while assigning values > array_drill(, , ); > ?> > i hope you guys would have understood what i mean. > kuldeep singh dhaka > kuldeepdhaka9@gmail.com > > > --047d7b603d725099ba04caea1b3e--