Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77805 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86324 invoked from network); 7 Oct 2014 16:14:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Oct 2014 16:14:40 -0000 Authentication-Results: pb1.pair.com header.from=mathiasgrimm@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mathiasgrimm@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: mathiasgrimm@gmail.com X-Host-Fingerprint: 209.85.223.181 mail-ie0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:57161] helo=mail-ie0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/AB-30869-07114345 for ; Tue, 07 Oct 2014 12:14:40 -0400 Received: by mail-ie0-f181.google.com with SMTP id at20so5613584iec.40 for ; Tue, 07 Oct 2014 09:14:37 -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=kkKsgylQLv9mJZzze0wwKKTnkVp5vi7mhDpYeHuXjzw=; b=Op7IcnldcGQTRa1X6cJk20qbKGnGQ2Adc/16WMxBX2nMftBB+TCcWhl6noYa3uHV+m Q+achtfo/bsWmYCgNcS1LLX8jg5MXWcEmBK+lSli+L7cCXxscHSkGQWcb/LrHZ4N+Z/v 9FBheKVrwQFb9z6JOs8xmIzlRoVdwInxPKqcsxo8Gd83gWwv21eejMVTOdrf51Ghgce7 pEcmiYT8lOb1g2oRxjKSJFpKxYh+z/UbmqLsvb55kr2gLbl6Bqm9OF5m2ZL5DKlxhYiV WM68mK24WqC50iZflhfMEpnGhaPSGLnWy0pNlJpVr11McXAeLedabTSyJAzETvpar98i PH1g== MIME-Version: 1.0 X-Received: by 10.50.176.202 with SMTP id ck10mr33934696igc.2.1412698477829; Tue, 07 Oct 2014 09:14:37 -0700 (PDT) Received: by 10.64.76.136 with HTTP; Tue, 7 Oct 2014 09:14:37 -0700 (PDT) In-Reply-To: References: Date: Tue, 7 Oct 2014 17:14:37 +0100 Message-ID: To: Florian Margaine Cc: PHP Internals Content-Type: multipart/alternative; boundary=089e0111d758f2464b0504d77eb6 Subject: Re: [PHP-DEV] ArrayPath From: mathiasgrimm@gmail.com (Mathias Grimm) --089e0111d758f2464b0504d77eb6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable default value and existence of index checking. I not a huge change, its a good change and very handy. array( 'basicInformation' =3D> array( 'name' =3D> 'Mathias', 'surname' =3D> 'Grimm' ), )); // normal php way$sName =3D isset($post['user']['basicInformation']['name' ]) ? $post['user']['basicInformation']['name' ] : null;$sSurname =3D isset($post['user']['basicInformation']['surname']) ? $post['user']['basicInformation']['surname'] : null; // default value$sLocale =3D isset($post['user']['locale']) ? $post['user']['locale'] : 'Europe/Dublin'; // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // ArrayPath$sName =3D ArrayPath::get('user/basicInformation/name' , $post);$sSurname =3D ArrayPath::get('user/basicInformation/surname' , $post); // with default value$sLocale =3D ArrayPath::get('user/locale', $post, 'Europe/Dublin'); On Tue, Oct 7, 2014 at 5:12 PM, Florian Margaine wrote: > Hi! > > How is it better than: > > $idx3 =3D $_POST['idx1']['idx2']['idx3']; > > ? > > Regards, > Florian Margaine > Le 7 oct. 2014 18:05, "Mathias Grimm" a =C3=A9cr= it : > > Hi, >> I would like to suggest something for php like a class I am using >> >> https://github.com/mathiasgrimm/arraypath >> >> The reason is to access arrays like this: >> >> $idx3 =3D ArrayPath::get('idx1/idx2/idx3', $_POST, 'myDefaultValue'); >> >> >> Regards, >> Mathias >> > --089e0111d758f2464b0504d77eb6--