unpack() misbehaves with 1 char string
| Bug #27384 | unpack() misbehaves with 1 char string | ||||
|---|---|---|---|---|---|
| Submitted: | 2004-02-24 15:17 UTC | Modified: | 2004-03-02 15:44 UTC | ||
| From: | hayk at mail dot ru | Assigned: | |||
| Status: | Closed | Package: | Strings related | ||
| PHP Version: | 4.3.4 | OS: | * | ||
| Private report: | No | CVE-ID: | None | ||
[2004-02-24 15:17 UTC] hayk at mail dot ru
Description:
------------
When the function unpack returns an array with just one element, it doesn't have an index.
Reproduce code:
---------------
<?
$sp = chr(0x20);
$a = unpack('C1', $sp);
?>
<pre>
<? print_r($a); ?>
</pre>
Expected result:
----------------
Array
(
[] => 32
)
Actual result:
--------------
Array
(
[1] => 32
)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-02-24 15:23 UTC] hayk at mail dot ru
[2004-02-24 15:30 UTC] gschlossnagle@php.net
[2004-02-24 15:42 UTC] hayk at mail dot ru
Why this code works fine? <? $sp = chr(0x20); $a = unpack('C2', $sp.$sp); ?> <pre> <? print_r($a); ?> </pre> We get: Array ( [1] => 32 [2] => 32 )[2004-02-24 16:42 UTC] gschlossnagle@php.net
[2004-02-25 07:29 UTC] sniper@php.net