Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77822 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32422 invoked from network); 7 Oct 2014 23:48:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Oct 2014 23:48:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=korvinszanto@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=korvinszanto@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.51 as permitted sender) X-PHP-List-Original-Sender: korvinszanto@gmail.com X-Host-Fingerprint: 209.85.192.51 mail-qg0-f51.google.com Received: from [209.85.192.51] ([209.85.192.51:56209] helo=mail-qg0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A9/E0-26902-8BB74345 for ; Tue, 07 Oct 2014 19:48:09 -0400 Received: by mail-qg0-f51.google.com with SMTP id z107so6141925qgd.24 for ; Tue, 07 Oct 2014 16:48:06 -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:content-transfer-encoding; bh=QkNtkhLFKE3rJtxkQMD6F9kzdBo2LfWNQ94BlYT+PA8=; b=rBWw+EvQgMYyx4zQgf3+IFtkHgRqRU09xe4EoeFJzqdIryJGNy+0ZPN2fNt29Vg7Si IGF0rEvkuYa4wa24WFYI4pkXq1IwSyvsFcBjcS6hklr0gfj1W8/Ij74GXCrTTaYHNdDh +KZ+5dVVD+74A2kyaru+tpvmtRGdBkgTCeB34MGCEdObPGqQ2i7U6Qer7dUzOGSOxTc7 p+7kx5y+KS+WeQBodRZzXe6ZZulO8YZuIBY7hcq4drO/K1TXZvB5hwt5F/KeYq8X8G/f Wx2i2hXDKnziGbScLCEiJU9h8y4rBh5kye6zzLH11wt/Qpx8gdEtBwJQmD/h1lBj5mZR NZcw== MIME-Version: 1.0 X-Received: by 10.224.119.197 with SMTP id a5mr6916249qar.104.1412725686579; Tue, 07 Oct 2014 16:48:06 -0700 (PDT) Received: by 10.140.42.119 with HTTP; Tue, 7 Oct 2014 16:48:06 -0700 (PDT) In-Reply-To: References: <1412702156.4712.215.camel@kuechenschabe> Date: Tue, 7 Oct 2014 16:48:06 -0700 Message-ID: To: Mike Willbanks Cc: =?UTF-8?Q?Johannes_Schl=C3=BCter?= , Mathias Grimm , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] ArrayPath From: korvinszanto@gmail.com (Korvin Szanto) In every project I have worked on in the last few years, I've implemented this. If I have an array that I can't be sure is well formed and need to get a value at any depth without triggering expensive notices, the recommended way today is to check if each value is set and is an array: http://3v4l.org/23c9i With this functionality, I can simply do: array_get('key1.key2', 'default') On Tue, Oct 7, 2014 at 11:18 AM, Mike Willbanks wrote: > On Tue, Oct 7, 2014 at 12:15 PM, Johannes Schl=C3=BCter > wrote: > >> On Tue, 2014-10-07 at 17:05 +0100, Mathias Grimm wrote: >> > 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'); >> >> what hppens if my array has a / as part of the key? Do I have to check >> that beforehand and set a custom identifier? So what happens if I use >> your example with $_GET instead of $_POST and a user requests >> foo.php?idx1=3Didx2/idx3 >> >> I'm not really convinced. >> > > > This request seems to be more in the realm of having XPath type support f= or > arrays, likewise people have also attempted to do this with JSON. It doe= s > seem like it could be valuable to some degree, however, I don't necessari= ly > believe it belongs in the core. This seems much better for a PECL module > if necessary. > > If the key has a / it would seem like you should escape it like a regular > string escape, aka "\/". I'm not convinced this is something that is > necessary in PHP either. There does not seem to be a great use case for > this use. > > > >> >> johannes >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >>