Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51886 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10075 invoked from network); 14 Apr 2011 10:16:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2011 10:16:50 -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:35286] helo=remus.fluks.no) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/EA-44901-099C6AD4 for ; Thu, 14 Apr 2011 06:16:50 -0400 Received: from localhost (localhost [127.0.0.1]) by remus.fluks.no (Postfix) with ESMTP id 53D4A503661; Thu, 14 Apr 2011 12:16:45 +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 OqxCe4-qPle7; Thu, 14 Apr 2011 12:16:43 +0200 (CEST) Received: from localhost (trh.betradar.com [92.62.38.2]) by remus.fluks.no (Postfix) with ESMTPA id BC8EB5035DF; Thu, 14 Apr 2011 12:16:43 +0200 (CEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Eloy Bote Falcon" Cc: "internals@lists.php.net" , "Ben Schmidt" References: <4D9E0543.1080600@lerdorf.com> <69.82.36433.EC33E9D4@pb1.pair.com> <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> Date: Thu, 14 Apr 2011 12:16:43 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: User-Agent: Opera Mail/11.10 (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 10:59:41 +0200, Eloy Bote Falcon wrote: > What is the purpose of that generateHash function? It doesn't work in the > isset check. > Instead of using a multi-dimensional array, I use a flat array. > Anyway, you can do a simple $a = array('foo'); isset($a[$x][$y][$z]) > without > notices at all unless any of $x $y or $z are not defined, you don't need > to > check the indexes one by one. > Well, the example was just for brevity. If you want a full-blown example: if (!isset($a[$x])) { $a[$x] = array(); } if (!isset($a[$x][$y])) { $a[$x][$y] = array(); } if (!isset($a[$x][$y][$z])) { $a[$x][$y][$z] = array(); } $a[$x][$y][$z] = 1; Hope this clarifies. -- Ole Markus