20
Initially, it seems a silly question. But my goal here is to come up with a more concrete concept regarding the array.
In languages such as Javascript, the array is an object that accepts you to add and remove members to a kind of list. This list always has the indexes numbered starting from 0.
In Python, we have something similar to array of Javascript, which would be the list and the tuple, except the latter which is an immutable but similar list.
However, in PHP, the array seems to be a mixture of hash (or as Object in Javascript) with a list.
As my first programming language was PHP, I got used to Array
being what it is in PHP, but when comparing with array of Java, Javascript and other languages, I see that even having the same nomenclature, they seem to be different things, generating a confusion of technical terms.
But after all, what is a array? Is it a sequentially indexed list? Or is it a container of manually indexed items (as in PHP)?
It would be correct to state that the PHP language array concept is wrong? If it is "wrong", what would be the most appropriate name for the "array" of this language?
List and array is the same thing? If not, what is the difference?
Related questions:
Name of stackoverflow moderator pt. D
– user28595
Would it be correct to say that the PHP Language Array concept is wrong? A: In a way yes, there are a thousand other things that have an inappropriate name in PHP. If you look closely, you will see that PHP "borrows" many resource names from other languages, but without the proper concept domain. Ex: 7 "type" system, OO behavior simulation, "define" imitation, etc
– Bacco
In the case of PHP, even what would be a simple array, is an associative: http://ideone.com/iEDhkz (and that’s why in the question about how to detect the difference, the most important thing was missing in most answers: no difference, pq pro PHP is always associative. Any detection that does not read the source code looking for the definition, will not differentiate pq the only difference is in the source, apparently).
– Bacco