note 20717 deleted from function.array-push by philip
| From: | philip@php.net | Date: | Fri, 09 Oct 2009 16:39:18 +0000 |
| Subject: | note 20717 deleted from function.array-push by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161594@lists.php.net to get a copy of this message | ||
Note Submitter: daniel at nomail dot com
----
If you want to use integer keys simply treat it as an 'ordinary' array.
<?php
$user_arr = array();
$user_id = 4;
$user_name = 'John';
$user_arr[$user_id] = $user_name;
$user_id = 346;
$user_name = 'Steve';
$user_arr[$user_id] = $user_name;
$user_id = 652;
$user_name = 'Maria';
$user_arr[$user_id] = $user_name;
?>
All slots in between the three user IDs will not be allocated and sizeof($user_arr) will return 3
and not 653.