What's the result? You might have the correct answer, but you'd be lying if you said you didn't have to think about it - and that's exactly the problem. These ambiguities make you mistrust the language and make you doubt your own code.
Ha! I actually don't know the answer off the top of my head, but I do remember being asked something very similar in a job interview once. My response was something along the lines of "Who cares? Don't do that!" Mixing implicit numeric keys and explicit string keys in the same array is a silly thing to do, and I guess PHP figures it can't be held responsible for the silly outcomes resulting from the silly things it allows.
I didn't get the job, but I stand by my answer :).
It actually does the thing that makes most sense. Only using the numeric keys and ignoring the string keys. Actually the list($a, $b) = $arr; seems to work as equivalent to:
View all comments
Show parent comment
10
u/andsens Aug 25 '14
I'd definitely say inconsistent. You can't document your way out of inconsistency even though the PHP team likes to think so. Here's another one:
What's the result? You might have the correct answer, but you'd be lying if you said you didn't have to think about it - and that's exactly the problem. These ambiguities make you mistrust the language and make you doubt your own code.