Re: Re: PHP 4.0 Bug #9307 Updated: Numeric-looking array keys are forced to be integers
| From: | Stanislav Malyshev | Date: | Tue, 06 Mar 2001 15:43:50 +0000 |
| Subject: | Re: Re: PHP 4.0 Bug #9307 Updated: Numeric-looking array keys are forced to be integers | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-48059@lists.php.net to get a copy of this message | ||
DC>> function some_generic_function($myarray)
DC>> {
DC>> foreach ($myarray as $k => $v) {
DC>> if (is_string($k)) {
DC>> /* some behaviour for associative array element */
DC>> }
DC>> else {
DC>> /* some behaviour for indexed array element */
DC>> }
DC>> }
DC>> }
Well, that's a bad code. Very bad. Why would you distinguish between
string and number keys? Anyway, there's no way (known to me) to do this in
PHP. If you tell me why would you need this, I could probably give some
advice (such as adding "k_" to each key, for example), but as a
theoretical example it just looks like "let's do something just because we
want, no matter that PHP is not meant to do that".
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115