Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
No edit summary
remove outdated "X links here" comments
Line 796:
</source>
 
=== PHP ===
=== PHP ===<!-- This section is linked from [[PHP]] -->
[[PHP]]'s built-in array type is in reality an associative array. Even when using numerical indexes, PHP internally stores it as an associative array.<ref>About the implementation of [http://se.php.net/manual/en/language.types.array.php Arrays] in PHP</ref> This is why one in PHP can have non-consecutive numerically indexed arrays. The keys have to be integer or string (floating point numbers are truncated to integer), while values can be of arbitrary types, including other arrays and objects. The arrays are heterogeneous; a single array can have keys of different types. PHP's associative arrays can be used to represent trees, lists, stacks, queues and other common data structures not built into PHP.
 
Line 1,010:
keys are stored in a separate associative array with numeric keys.
 
=== Ruby ===<!-- This section is linked from [[
Constructing and using a [[hash table
Ruby (programming language)]] -->
 
In [[Ruby programming language|Ruby]] a [[hash table|hash]] is used as follows:
Line 1,056 ⟶ 1,054:
<source lang=C>
foreach name (phonebook) {
vmessage ("%s %s", name, phonebook[name]);
}
</source>