php-general | 2000071
Date: 07/07/00
- Next message: Ed Vul: "Re: [PHP] open/save dialog on page load"
- Previous message: Andrei Zmievski: "Re: [PHP] str_pad() proposed changes"
- Next in thread: Carroll Barrett: "Re: [PHP] using integers as array keys"
- Maybe reply: Carroll Barrett: "Re: [PHP] using integers as array keys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In PHP, I always find myself trying to create hashes with integer keys,
only to rediscover that using an integer index in a PHP associative
array is essentially meaningless. Common example: a query returns a list
of integers which are keys into the database table. I want to simply
stuff those integers into a hash and not worry about the fact that PHP
uses this combination hash/array concept.
$myarray = array();
$myarray[567] = 1;
$myarray[31416] = 1;
// $myarray[0] already isset() !
// $myarray[1] already isset()!
// ... time passes
// is $myarray[27] set?
// who knows?
I could so something wasteful and do $array['my_id_'. $id] = 1, but that
would be silly. Is there a way to get associative arrays more like Perl?
Is there any alternative?
Thanks,
-- // Alex <email protected> // Programmer, Panorama Point web development // New Mexico, USA // 505-424-4800x35-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Ed Vul: "Re: [PHP] open/save dialog on page load"
- Previous message: Andrei Zmievski: "Re: [PHP] str_pad() proposed changes"
- Next in thread: Carroll Barrett: "Re: [PHP] using integers as array keys"
- Maybe reply: Carroll Barrett: "Re: [PHP] using integers as array keys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

