[ABE.pm] php and me

Andy Armstrong andy at hexten.net
Mon Aug 11 10:09:57 PDT 2008


On 11 Aug 2008, at 17:50, Ricardo SIGNES wrote:
> I knew that arrays had multiple-personality disorder, but it seems  
> even wackier
> than I thought.  I have a sinking feeling that validing that  
> something is a
> sequence (which means something like "an ordered list of values") or  
> a record
> (which is something like "a group of named values") is going to be  
> hard to get
> just right.  I think I will need to allow arrays for both and also  
> stdClass
> objects for records.


As far as I know all you can do is assume that if the subscripts are  
all integers, start at zero and there are no gaps in the numbering  
that it's an array. In particular you'll be pleased to note that an  
empty array IS an empty hash - there is no way they can be  
distinguished because they're the same thing.

PHP's own JSON encoder treats empty things as arrays rather than hashes:

     print json_encode(array());
     []

Fun :)

-- 
Andy Armstrong, Hexten





More information about the ABE-pm mailing list