Using isset(), there is a potential problem that escaped me until
today. You can get false positives from isset on associative arrays.

$data['Modelname']['field1'] = 'some string';
isset($data['Modelname']['field1']) => true as I would expect

$data['Modelname'] = 'some string';
isset($data['Modelname']['field1']) => true although I didn't think
that would be the case.

This is apparently because the variable being checked is a string but
I expected it to be an array. Checking for a "key" on a string will
always return true. I first thought my PHP install was broken but I
found some comments on php.net that makes me think this is just
something that has slipped me by all this time.
http://www.php.net/manual/en/function.isset.php#89651

So be careful if you are checking and you are not sure you have an
array or not.

Sorry for the OT topic, I hope someone find it useful since we do a
lot of array juggling in Cake and pinning down the cause can be a
pain. Well, now you know what I did for an hour this afternoon.
/Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to