#50401 [Opn->Bgs]: Array Key Data Type Conversion
| From: | rasmus@php.net | Date: | Mon, 07 Dec 2009 20:25:45 +0000 |
| Subject: | #50401 [Opn->Bgs]: Array Key Data Type Conversion | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-145495@lists.php.net to get a copy of this message | ||
ID: 50401
Updated by: rasmus@php.net
Reported By: michael dot patrick dot mcnally at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Windows Vista
PHP Version: 5.3.1
New Comment:
This is part of being a dynamically typed language aimed at the Web.
There are no types in an HTTP request. Everything comes across as
strings, or just data, if you will. PHP tries to make sense of that
data in the most logical way. This isn't going to change.
If you need stronger typing, you need to apply some logic on your own
to achieve that. Like keep a separate array for user-changeable
options, for example.
Previous Comments:
------------------------------------------------------------------------
[2009-12-07 20:20:06] michael dot patrick dot mcnally at gmail dot com
Description:
------------
It is necessary that I check to see if an array key has been set by the
code. Such as is with this code:
foreach($array as $key => $value){
if(is_int($key)) echo 'the code assigned a key for this element';
}
How can I achieve this with the following array?:
array('1'=>'Yes','0'=>'No');
PHP converts the '1' into 1 which leaves me no detection for user
assigned keys. This is bad form.
Reproduce code:
---------------
---
From manual page: language.types.array
---
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50401&edit=1