Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91139 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37467 invoked from network); 9 Feb 2016 08:10:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2016 08:10:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.204 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.204 mail4.serversure.net Linux 2.6 Received: from [217.147.176.204] ([217.147.176.204:39476] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/D1-15491-6DE99B65 for ; Tue, 09 Feb 2016 03:09:59 -0500 Received: (qmail 24599 invoked by uid 89); 9 Feb 2016 08:09:53 -0000 Received: by simscan 1.3.1 ppid: 24592, pid: 24595, t: 0.0698s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.7?) (lester@rainbowdigitalmedia.org.uk@81.155.186.161) by mail4.serversure.net with ESMTPA; 9 Feb 2016 08:09:53 -0000 References: <56B8BA24.7040003@lsces.co.uk> To: "internals@lists.php.net" Message-ID: <56B99ED0.2030102@lsces.co.uk> Date: Tue, 9 Feb 2016 08:09:52 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Proposal for a new array function From: lester@lsces.co.uk (Lester Caine) On 09/02/16 02:52, Yasuo Ohgaki wrote: > Hi, > > On Tue, Feb 9, 2016 at 1:03 AM, Kinn Julião wrote: >> And what's wrong with doing: >> https://gist.github.com/kinncj/566bbc019be5707b01f2 ? > > Perfectly ok to me while it would be slower. > > BTW, it's easy and quick to detect array is real array with PHP7. > It would be handy if kind of array can be returned. It should be > different API. is_array() may be extended. > > bool is_array(mixed $var [, bool $is_real_array]); > > or > > bool is_array(mixed $var [, long $type_of_array]); > > where $type_of_array is bit flags such as PHP_ARRAY_REAL, > PHP_ARRAY_HASH, PHP_ARRAY, PHP_ARRAY_RECLUSIVE, etc. That was what I was thinking about ... It's all very well saying that the top layer of an array is 'simple numeric', but the whole power of PHP is that each of those elements of the array can be something different so a simply boolean answer seems a little lacking? This looks like a nice alternative to adding yet more functions, but an 'array_type' function returning '$type_of_array' makes a lot of sense especially if the internal structure can maintain the information? I may not like 'strict typing' of things, but that is because I can do is_int and is_array to check for a single record id or a list of them, and is_array_simple which returns true for an array which is just a simple list of numbers or is_array_recursive for one where the list has already been expanded to a list of objects would complete my tool kit. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk