Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77806 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87854 invoked from network); 7 Oct 2014 16:19:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Oct 2014 16:19:16 -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.175 as permitted sender) X-PHP-List-Original-Sender: mathiasgrimm@gmail.com X-Host-Fingerprint: 209.85.223.175 mail-ie0-f175.google.com Received: from [209.85.223.175] ([209.85.223.175:45925] helo=mail-ie0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/FB-30869-28214345 for ; Tue, 07 Oct 2014 12:19:15 -0400 Received: by mail-ie0-f175.google.com with SMTP id x19so5725869ier.34 for ; Tue, 07 Oct 2014 09:19:11 -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=EynO7DcEp3lgoL3o7IS/zI7u1FtQ1m6ytuIQCq4B714=; b=ydpyEhyT/DtfjqyKke1OHA8Yx35N2b0ECPTN0mW7Na/zbWRCw+mnZ3jXhbP9WGp4mk ByVJZOTozgjoUjlQ89/9ZLKwhMzDtsKr+njhXjYqu9Mr0Z/18i1iZWXlWPgwvBwZdKXR Ktk0Ikr1Fh5dV2qVSKPEx9LVGgP1JP6i31lUTfKCWh6XvnOMvgzZRw/BOJ70rEHqCNYi +V/bURbYtsUyx9SMmPv09qsL2OlhZZ9yjUOapHY6YBmg/fvDn8fFueo7JTHnGVqpEAV7 O+2EhytrUtRAZ8/ip+hKjsDtdDxngoC6D1w4yyexeZRM+fEkaW9OX4MHrSuGTqgWJQva 4kiA== MIME-Version: 1.0 X-Received: by 10.42.39.7 with SMTP id f7mr6106985ice.93.1412698751563; Tue, 07 Oct 2014 09:19:11 -0700 (PDT) Received: by 10.64.76.136 with HTTP; Tue, 7 Oct 2014 09:19:11 -0700 (PDT) In-Reply-To: References: Date: Tue, 7 Oct 2014 17:19:11 +0100 Message-ID: To: Florian Margaine Cc: PHP Internals Content-Type: multipart/alternative; boundary=20cf30223ca742ff5e0504d78ffc Subject: Re: [PHP-DEV] ArrayPath From: mathiasgrimm@gmail.com (Mathias Grimm) --20cf30223ca742ff5e0504d78ffc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This is handy just for programmers using recommended php.ini settings for development (error_reporting =3D E_ALL and display_errors =3D On). People using @, display_errors =3D Off or any other sort of sorcery don't have such problems. On Tue, Oct 7, 2014 at 5:14 PM, Mathias Grimm wrote: > default value and existence of index checking. > > I not a huge change, its a good change and very handy. > > 'user' =3D> array( > 'basicInformation' =3D> array( > 'name' =3D> 'Mathias', > 'surname' =3D> 'Grimm' > ), > )); > // normal php way$sName =3D isset($post['user']['basicInformation']['n= ame' ]) ? $post['user']['basicInformation']['name' ] : null;$sSurname = =3D isset($post['user']['basicInformation']['surname']) ? $post['user']['ba= sicInformation']['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' , $po= st); > // 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=A9c= rit : >> >> 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 >>> >> > --20cf30223ca742ff5e0504d78ffc--