Robert Spier on Tue, 29 Feb 2000 00:33:45 -0500 (EST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: php arrays


>>>>> "m" == mjd-perl-pm  <mjd-perl-pm@plover.com> writes:

  >> 2) all keys to arrays are stringified

  m> Not necessarily.  Try using an object as a key, then retrieve it
  m> with the `keys' function, and see if you can still call a method
  m> on it.

    $foo = new someclass;
    $arr[ $foo ] = 'somevalue';

    causes.

Warning: Illegal index type in /home/rspier/public_html/ar1.php3 on
line 16

    $foo = new someclass;
    $arr[ "$foo" ] = 'somevalue';
    
    leads to a key with value "Object" (the String "Object")

    Therefore -- I think 2) above is correct, assuming there is a
reasonable string representation.  (So, only strings and numbers can
be used as keys.)

-R

**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**


  • Follow-Ups: