Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Difference between array and a hash? (Newbie concerns)

by hobbs (Monk)
on Jul 30, 2009 at 03:02 UTC ( #784454=note: print w/replies, xml ) Need Help??

in reply to Difference between array and a hash? (Newbie concerns)

Basically every "array" in PHP is an array and a hash, glued together. All of the values are stored in the hash as key/value pairs, but there's an array stored along with it that gives an ordering to the keys. The thing is, most of the time you either need one behavior (in-order processing) or the other (random lookup), and not both. PHP is giving you the overhead of both at all times; Perl is requiring you to say which one you really want. In the case where you really do need both methods, it's not very hard to set up the necessary parallel data structure in your own code, but Tie::IxHash is another option.

Replies are listed 'Best First'.
Re^2: Difference between array and a hash? (Newbie concerns)
by Anonymous Monk on Jul 30, 2009 at 03:28 UTC
    In perl that used to be called pseudohash, but they were removed.
      Pseudohash goes the other way, though. Pseudohashes were arrays internally, with a hash glued on so that the items could be accessed by key. The "ordered hash" as provided by PHP or IxHash is a hash primarily, with an array glued on to provide an ordering.
        Those are implementation details, not really relevant to how you use either

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://784454]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-08-09 01:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found