php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21396 after $var =pack(...) with 'N' flag, if use $var in $tmp[$var]='v' key is empty
Submitted: 2003-01-03 14:24 UTC Modified: 2003-01-04 06:18 UTC
From: slach at ems dot ru Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.2.3 OS: w2k, linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: slach at ems dot ru
New email:
PHP Version: OS:

 

 [2003-01-03 14:24 UTC] slach at ems dot ru
just see code
<?
error_reporting(E_ALL);

$aa = pack("N",127);
$bb = pack("N",65);
$cc = pack("N",121344231);

echo "$aa\n";
echo "$bb\n";
echo "$cc\n";

$tmp=array();

$tmp[$aa] = "aa";
$tmp[$bb] = "bb";
$tmp[$cc] = "cc";

var_dump($tmp);
?>

output:

A
;??
array(3) {
  [""]=>
  string(2) "aa"
^^^^^^^ but needed [""] => "aa" ???
  [""]=>
  string(2) "bb"
  [";??"]=>
  string(2) "cc"
}

WHY ?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-04 06:18 UTC] sniper@php.net
RTFM: http://www.php.net/manual/en/language.types.array.php

"A key is either an integer or a string"
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 22:01:36 2025 UTC