Newsgroups: php.internals,php.qa Path: news.php.net Xref: news.php.net php.internals:63253 php.qa:66730 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86792 invoked from network); 30 Sep 2012 16:53:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Sep 2012 16:53:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=eitan@mosenkis.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=eitan@mosenkis.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain mosenkis.net designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: eitan@mosenkis.net X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:45266] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4F/90-16417-AF878605 for ; Sun, 30 Sep 2012 12:53:15 -0400 Received: by lbbgm13 with SMTP id gm13so1241240lbb.29 for ; Sun, 30 Sep 2012 09:53:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=dkim-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:x-gm-message-state; bh=c5NdpCJZaw0U9DxDP8bODZwfxKQOW71Sg0lkXB0xOFA=; b=Sroh9cn5WKXufRNkTTncPJ4ilB+geLG381m3gQHgl64I5XJyp115FPaPIUc/5qLiPp 9BntAVpgmHgl0lfv6PAO/dyWTax1oOMaQHadK1QBuA+ms7uGTJINmquixXF7HWoxqW4O CC9nA8JwkcuTYNn7rSuCnbq8HtPF0zMSUzRSI8/xcWs+TIp5LGw/RhVw8saHHZZH2Z7v YMv3Ju1GEm6q2OHLd7hXi8q4ugiUijPbso5+tg0HIi99DE6RCvUOaR6qVdGfPd6LBbml +V++DONkCAj3zeEf5sAvns8eEK6ezPgFeuLbFC5Jpno9iM2o/4BS9UpJiOOJCIXSkoCU +0MA== Received: by 10.152.48.102 with SMTP id k6mr9876347lan.12.1349023991222; Sun, 30 Sep 2012 09:53:11 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com [209.85.217.170]) by mx.google.com with ESMTPS id p7sm3875420lbg.17.2012.09.30.09.53.09 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 30 Sep 2012 09:53:10 -0700 (PDT) Received: by lbbgm13 with SMTP id gm13so1241223lbb.29 for ; Sun, 30 Sep 2012 09:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mosenkis.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=c5NdpCJZaw0U9DxDP8bODZwfxKQOW71Sg0lkXB0xOFA=; b=d//OE0jDflgaM4L8Axyo4Wf1jaLjEU6txyEsxC7We4Sq3QeIwBG/ijxjMX3FoOMrpD nErR5haEKhbOvGG+dafmH7n6W2Y2f6MTKNq8hcrBx1b0NnQdrKb2KoGDfvPx2qg4OqXl Ti2lqbLiQyX8usEQ21YnZUwLZdWt/ABI9dfeM= Received: by 10.112.42.33 with SMTP id k1mr4448545lbl.96.1349023988551; Sun, 30 Sep 2012 09:53:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.106.36 with HTTP; Sun, 30 Sep 2012 09:52:48 -0700 (PDT) In-Reply-To: References: <781C00C3309B4CAFB5E4B612E94A46C1@charliesomerville.com> Date: Sun, 30 Sep 2012 12:52:48 -0400 Message-ID: To: Anthony Ferrara Cc: Charlie Somerville , kuldeep dhaka , Ferenc Kovacs , php-qa@lists.php.net, PHP Internals Content-Type: multipart/alternative; boundary=e0cb4efe358ea18f3e04caee1f80 X-Gm-Message-State: ALoCoQnDrJBbCjJQHLSY+D8NrvX4H+FdO9U3YuTZyMlBAkc3i9WOYLs6S4vsC1xH14y5L2j+qQ9B Subject: Re: [PHP-DEV] Funny array function From: eitan@mosenkis.net (Eitan Mosenkis) --e0cb4efe358ea18f3e04caee1f80 Content-Type: text/plain; charset=UTF-8 Those look good except that you're using isset($ar[$key]) when you should be using array_key_exists($key, $ar). If the value you were trying to set is set to null, your function will erroneously return false instead of null (since it isn't 'set', but the key does in fact exist) On Sun, Sep 30, 2012 at 8:03 AM, Anthony Ferrara wrote: > Yes, it's fairly trivial to write a function for this. I wrote a pair of > them in about 2 minutes: > > http://codepad.viper-7.com/rqVlqL > > > > On Sun, Sep 30, 2012 at 7:56 AM, 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 (mailto:kuldeepdhaka9@gmail.com) > > > > > > > > > > > > > --e0cb4efe358ea18f3e04caee1f80--