Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98979 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51234 invoked from network); 6 May 2017 15:42:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 May 2017 15:42:58 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.171 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.128.171 mail-wr0-f171.google.com Received: from [209.85.128.171] ([209.85.128.171:36075] helo=mail-wr0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/1E-02776-00FED095 for ; Sat, 06 May 2017 11:42:57 -0400 Received: by mail-wr0-f171.google.com with SMTP id l50so17394254wrc.3 for ; Sat, 06 May 2017 08:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=7y1Mwr3ScKNqVQ54VXCbuoyxCklOugWPXmYgNCE8U8s=; b=jPCajrB314tTv8gNACsC98QxSjdkdn148g0pkSUsFyb7mdy8Insb6NfKNBEMIw/noY AxgcMXZq4n1lw/kMQqXDlYIxa03B8dGDfI3+kNochKjgcXwWdA9+DwiDD5tE2rywqvzY Kre5Z2ssrEdHEwgKG9v0zZbW87nVABRtboU414l2iHD7ahRkA0ITBXqkp+Tnfpu+lrEj BG4VFOhCTNtwSMCuDsPmCzEGacuSRX/9ZsPHa5E48pFfXDPYPuwN8oh2w515xFHcFUmh Yg7HWbxJk7RT0q7OpGOqTsUKxeWQhU5u7rPuzrwTpDjFSyjxFInYi5k0yNvITVzwD8im uZlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=7y1Mwr3ScKNqVQ54VXCbuoyxCklOugWPXmYgNCE8U8s=; b=YdQ7e/LNzmQ16GVqR9cJT40ISffNjE8RHW+EawSVSXcDrrBBj1pk0L4Gfx2BPAj5cs FryY8cl3N0v54cmsbm5cl81QR8oi/oTy5EX8f2GedvaVzC4wqOKmnVEwavjdGMYsBQJn yjr+AvuzxvNrbfOjBmcABSGh4RejGz+BosugWd/j/xrAUpikm8K47AiIffPgGCA9t92h ppG9vQVrIgp7xxBhgnfmieo/coCsH1J31kpSoTLYwcP/Al+lIEVCYyKurA9Ve44rBOvk qidFqTGca+lGa9IRxXJTDPu65B7hdr92AxEp2hkY1GYqq6DiUOnIxOIst0KxqoP5trTo Rf8A== X-Gm-Message-State: AN3rC/5p/7BVNKpKohA/PubUOo43AtYl9z5iWIjPbcghPNc/qkD6kGR8 2PFgT8IYOBDSd/Ju X-Received: by 10.223.160.70 with SMTP id l6mr36109940wrl.0.1494085372987; Sat, 06 May 2017 08:42:52 -0700 (PDT) Received: from ?IPv6:2a00:23c4:4bd2:6e00:5db3:144b:29da:8d8b? ([2a00:23c4:4bd2:6e00:5db3:144b:29da:8d8b]) by smtp.gmail.com with ESMTPSA id 92sm7887468wra.0.2017.05.06.08.42.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 May 2017 08:42:51 -0700 (PDT) Date: Sat, 06 May 2017 16:42:49 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net Message-ID: <8FCFC367-D5B9-4259-BCAF-05C061F23F52@gmail.com> Subject: Re: [PHP-DEV] Add is_vectorlike($array) function From: rowan.collins@gmail.com (Rowan Collins) On 5 May 2017 22:19:51 BST, Ryan Pallas wrote: >I just read this thread and am wondering what exactly is the use case? >Like >are you going to do something if it is vector-like, and do something >different (or not do anything at all) if it's not vector-like? I mean, >if >you have to crawl it, and need a vector, why not just call array_values >and >guarantee you have a vector? I gave one use case in an earlier message: many serialisation formats have= a different form for ordered lists vs key-value pairs=2E As an obvious exa= mple, look at JSON arrays and objects, and many other formats have similar = types=2E It can also be quite intuitive to have a function accept either a list of = prepared items or a set of key-value pairs representing structured data=2E = For instance, HTTP headers might be prepared like ['User-Agent: example'] o= r structured like ['User-Agent' =3D> 'example']=2E Turning the second into = the first requires more than just running array_values, but can be skipped = if the input is known to be vector-like=2E Arrays that have integer keys, but not all sequential, can be a bit of an = edge case, but treating them as a list throws away information, so it's usu= ally safer to treat them as key-value pairs=2E Regards, --=20 Rowan Collins [IMSoP]