note 88153 added to function.array-count-values
| From: | Anonymous at osu1 dot php dot net | Date: | Tue, 13 Jan 2009 07:39:11 +0000 |
| Subject: | note 88153 added to function.array-count-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149128@lists.php.net to get a copy of this message | ||
@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));
?>
----
Server IP: 64.71.164.2
Probable Submitter: 24.11.209.231
----
Manual Page -- http://www.php.net/manual/en/function.array-count-values.php
Edit -- https://master.php.net/note/edit/88153
Del: integrated -- https://master.php.net/note/delete/88153/integrated
Del: useless -- https://master.php.net/note/delete/88153/useless
Del: bad code -- https://master.php.net/note/delete/88153/bad+code
Del: spam -- https://master.php.net/note/delete/88153/spam
Del: non-english -- https://master.php.net/note/delete/88153/non-english
Del: in docs -- https://master.php.net/note/delete/88153/in+docs
Del: other reasons-- https://master.php.net/note/delete/88153
Reject -- https://master.php.net/note/reject/88153
Search -- https://master.php.net/manage/user-notes.php