Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51906 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66266 invoked from network); 14 Apr 2011 16:20:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2011 16:20:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=olemarkus@olemarkus.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=olemarkus@olemarkus.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain olemarkus.org from 213.236.166.183 cause and error) X-PHP-List-Original-Sender: olemarkus@olemarkus.org X-Host-Fingerprint: 213.236.166.183 unknown Received: from [213.236.166.183] ([213.236.166.183:34169] helo=remus.fluks.no) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/B0-59898-8DE17AD4 for ; Thu, 14 Apr 2011 12:20:41 -0400 Received: from localhost (localhost [127.0.0.1]) by remus.fluks.no (Postfix) with ESMTP id 8CE95503778; Thu, 14 Apr 2011 18:20:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at fluks.no Received: from remus.fluks.no ([127.0.0.1]) by localhost (remus.fluks.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U7Sj53FAYJc5; Thu, 14 Apr 2011 18:20:36 +0200 (CEST) Received: from localhost (7.233.16.62.customer.cdi.no [62.16.233.7]) by remus.fluks.no (Postfix) with ESMTPA id BC80E503742; Thu, 14 Apr 2011 18:20:35 +0200 (CEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Martin Scotta" Cc: RQuadling@googlemail.com, "Richard Quadling" , "Eloy Bote Falcon" , "Ben Schmidt" , "internals@lists.php.net" References: <4D9E34C4.5000406@lerdorf.com> <4D9E429B.20503@sugarcrm.com> <4D9E96B6.6060401@lerdorf.com> <718216446.20110408143441@cypressintegrated.com> <4DA0E71C.9030008@gmail.com> <4DA63ED8.4080402@yahoo.com.au> <4DA6F2BC.10706@yahoo.com.au> Date: Thu, 14 Apr 2011 18:20:05 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: User-Agent: Opera Mail/11.00 (Linux) Subject: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: olemarkus@olemarkus.org ("Ole Markus With") On Thu, 14 Apr 2011 15:25:45 +0200, Martin Scotta wrote: > arrays are intent for holding values, not for represent things so use > objects for that. > the need for array_key_exists/isset to check for the presence of an > index is > a smell that you need to refactor your code for a different datatype. > There is quite a difference in performance between using an array representation of data structures such as graphs, matrices, etc and using an OO representation. Also with the inclusion of closures it is possible to write very elegant code using arrays and array functions such as array_walk, array_map etc. If the multi-dimensional array is sparse, you cannot really avoid a lot of isset calls. Also, if you want to output everything as json in the end, working on arrays is very natural. -- Ole Markus