note 104465 added to book.array
| From: | Ray dot PaseurGmail at osu1 dot php dot net | Date: | Thu, 16 Jun 2011 14:53:37 +0000 |
| Subject: | note 104465 added to book.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180613@lists.php.net to get a copy of this message | ||
The comment here is factually inaccurate:
http://us2.php.net/manual/en/book.array.php#96219
PHP loose data typecasting is applicable to array keys, and if you use a numeric string for an array
key, you will get a numbered index. And it will overwrite any existing numbered index in the array.
This script outputs:
array(1) { [3000000000]=> bool(true) } array(1) { [3000000000]=> bool(true) }
<?php // RAY_temp_johnmarc.php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);
// KEY AS INTEGER
$key = 3000000000;
$DATA[$key] = true;
var_dump($DATA);
// KEY AS INTEGER, BUT CAST AS STRING
$key = 3000000000;
$DATA["$key"] = true;
var_dump($DATA);
----
Server IP: 64.71.164.2
Probable Submitter: 98.169.58.122
----
Manual Page -- http://www.php.net/manual/en/book.array.php
Edit -- https://master.php.net/note/edit/104465
Del: integrated -- https://master.php.net/note/delete/104465/integrated
Del: useless -- https://master.php.net/note/delete/104465/useless
Del: bad code -- https://master.php.net/note/delete/104465/bad+code
Del: spam -- https://master.php.net/note/delete/104465/spam
Del: non-english -- https://master.php.net/note/delete/104465/non-english
Del: in docs -- https://master.php.net/note/delete/104465/in+docs
Del: other reasons-- https://master.php.net/note/delete/104465
Reject -- https://master.php.net/note/reject/104465
Search -- https://master.php.net/manage/user-notes.php