[Pmwiki-users] Some issues with the latest pmwiki release

Jonathan Scott Duff duff at pobox.com
Tue Apr 29 10:37:55 CDT 2003


On Tue, Apr 29, 2003 at 10:20:37AM -0500, Jonathan Scott Duff wrote:
> On Tue, Apr 29, 2003 at 09:59:32AM -0500, Patrick R. Michaud wrote:
> > Also, arrays in PHP (like perl) aren't quite as sparse as one might
> > like.  Thus something stored at element 700 means that elements 0 through
> > 699 are automatically created and eat up some space.  So, there's
> > some reason to keep the numbers small -- 0..70 takes up one tenth of
> > the memory as 0..700.  
> > 
> > Floating point numbers as indices aren't an option in PHP.  I'd have
> > to go to strings in that case, and of course sorting strings introduces
> > weird things (e.g., "11" comes before "2") and so it seems that just
> > sticking with integers is best.
> 
> For some reason I thought that arrays in PHP were all indexed "by
> string"  such that $a[700] can exist independant of $a[0]...$a[699].
> Same for using floating point numbers as indices.

http://www.php.net/manual/en/language.types.array.php

That reads to me like PHP has one type of array and it tries to be
smart enough to do what you mean when you specify integer or string
indices.  So if you just use "numeric strings" like so:

$array["1.2"] =  ... ;
$array["1.25"] =  ... ;
$array["1.2356"] =  ... ;

All is well.  (of course you'll have to ksort() the array before you
use it, but you should be doing that anyway)

-Scott
-- 
Jonathan Scott Duff
duff at cbi.tamucc.edu




More information about the pmwiki-users mailing list