Re: Implicit isset/isempty check on short-ternary operator
| From: | Ole Markus With | Date: | Thu, 14 Apr 2011 10:16:43 +0000 |
| Subject: | Re: Implicit isset/isempty check on short-ternary operator | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51886@lists.php.net to get a copy of this message | ||
On Thu, 14 Apr 2011 10:59:41 +0200, Eloy Bote Falcon <eloybote@gmail.com> 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