title: Associative Array versus SplObjectStorage
body: <p>I'm working on code to manage a collection of unique objects.  The first prototype of this code utilises an associative array, basically as that's the way I've always done it.</p>
  <p>However, I'm also keen on taking advantage of functionality that's been added to more modern versions of PHP such as <code>[SplObjectStorage][1]</code> for doing this instead, partly as a learning experience, partly because it's bound to offer advantages (benchmarks I've seen suggest that <code>SplObjectStorage</code> can be faster than arrays in a lot of cases).</p>
  <p>The current implementation has an associative array that I check with <code>in_array()</code> to see if an object is already in the array before adding a new object to it.</p>
  <p>The big problem I can see with <code>SplObjectStorage</code> is that it doesn't seem (at first glance) to support key/value associative array behaviour, and can only be treated as an indexed array. However, the documentation for the newer features of PHP isn't up to the standards of the documentation of more established parts of the language and I might simply be missing something.</p>
  <p>Can I use <code>SplObjectStorage</code> in place of an associative array? If so, how do I define the key when adding a new object?  More importantly, what are the relative advantages and disadvantages of <code>SplObjectStorage</code> when compared to associative arrays?</p>