note 96219 added to book.array
| From: | JohnMarc at osu1 dot php dot net | Date: | Mon, 15 Feb 2010 21:30:25 +0000 |
| Subject: | note 96219 added to book.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165986@lists.php.net to get a copy of this message | ||
Be careful when adding elements to a numeric array.
I wanted to store some info about some items from a database and decided to use the record id as a
key.
$key=3000000000;
$DATA[$key]=true;
This will create an array of 30 million elements and chances are, you will use up all memory with
these 2 lines
$key=3000000000;
$DATA["$key"]=true;
This on the other hand will force the array to be an associative array and will only create the one
element
----
Server IP: 69.147.83.197
Probable Submitter: 71.211.175.208
----
Manual Page -- http://www.php.net/manual/en/book.array.php
Edit -- https://master.php.net/note/edit/96219
Del: integrated -- https://master.php.net/note/delete/96219/integrated
Del: useless -- https://master.php.net/note/delete/96219/useless
Del: bad code -- https://master.php.net/note/delete/96219/bad+code
Del: spam -- https://master.php.net/note/delete/96219/spam
Del: non-english -- https://master.php.net/note/delete/96219/non-english
Del: in docs -- https://master.php.net/note/delete/96219/in+docs
Del: other reasons-- https://master.php.net/note/delete/96219
Reject -- https://master.php.net/note/reject/96219
Search -- https://master.php.net/manage/user-notes.php