Re: Implicit isset/isempty check on short-ternary operator

From: Date: Thu, 14 Apr 2011 16:20:05 +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-51906@lists.php.net to get a copy of this message
On Thu, 14 Apr 2011 15:25:45 +0200, Martin Scotta <martinscotta@gmail.com> 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

« previous php.internals (#51906) next »