2 ms·
Mix of array and hash types, combined with automatic type conversion has one very ugly gotcha: $x[1] === $x['1']. However, other than that I don't have problem
by pornel 16y ago
Mix of array and hash types, combined with automatic type conversion has one very ugly gotcha: $x[1] === $x['1'].
However, other than that I don't have problems with PHP's "arrays".
I find ordered key-value datatype very useful in lots of situations — all kinds of mappings ordered by priority, queues where you can remove any item quickly, trees where order matters (e.g. stuff coming from XML).
Sometimes even in cases where order doesn't strictly matter, preserving order makes operations more predictable and results easier to compare (e.g. you can load ini file to PHP "array", edit and save, and it won't get shuffled).
It might be a matter of how you think about your data: whether you think of it as arrays and hashes and try to retrofit it in PHP, or whether you think of mapping it into PHP's peculiar "array" from the start.