[development] Note that PHP arrays are fast

Rob Barreca rob at electronicinsight.com
Tue Apr 10 02:35:33 UTC 2007


> $flip = array('even' => 'odd', 'odd' => 'even');
> $class = $flip[$class]; 
I think the second is more readable too and allows us to easily to 
chains if we want tri-color rows or rainbows. :)
> $flip = array('light' => 'dark', 'dark' => 'medium', 'medium' => 
> 'light');
> $class = $flip[$class]; 
Rob Roy Barreca
Founder and COO
Electronic Insight Corporation
http://www.electronicinsight.com
rob at electronicinsight.com



Greg Knaddison - GVS wrote:
> On 4/9/07, Rob Thorne <rob at torenware.com> wrote:
>> While I use these kind of array tricks all the time (love that table
>> driven code),  the advantage of the first form is readability.  Unless
>> code like that is called many times in a request, I'd still go with the
>> ?: operator, since the intent is clearer.
>>
>> Remember: we have to maintain this stuff after we write it.
>
> I actually thought the second was more readable...
>
> Is there a consensus on the readability?
>
> Greg


More information about the development mailing list