note 88153 deleted from function.array-count-values by danbrown
| From: | danbrown@php.net | Date: | Tue, 13 Jan 2009 07:50:44 +0000 |
| Subject: | note 88153 deleted from function.array-count-values by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149130@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
@psbauman
In PHP (and every other programming language) leading zeros are stripped from numbers.
Since 0001097 is the exact same value as 1097. In other words... 0001097 == 1097. If you want to
maintain the leading zeros you would need to make the values a string.
<?php
$id_numbers[] = '0056789';
$id_numbers[] = '0012345';
$id_numbers[] = '0012345';
?>
This will yield the result you're looking for.
Also, there is no reason to use array_values in this situation:
<?php
$ids = array();
$ids[] = 'a';
$ids[] = 'b';
$ids[] = 'c';
// These two arrays will be identical
print_r($ids);
print_r(array_values($ids));
?>