php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44567 json_encode return unexpected result on uncontinues array
Submitted: 2008-03-30 05:57 UTC Modified: 2008-03-30 14:23 UTC
From: xiezhenye at gmail dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.2.5 OS: any
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: xiezhenye at gmail dot com
New email:
PHP Version: OS:

 

 [2008-03-30 05:57 UTC] xiezhenye at gmail dot com
Description:
------------
json_encode return unexpected result on uncontinues array.


Reproduce code:
---------------
$a = array(1,2,3);
echo json_encode($a),"\n";
unset($a[1]);
echo json_encode($a),"\n";

Expected result:
----------------
[1,2,3]
[1,3]


Actual result:
--------------
[1,2,3]
{"0":1,"2":3}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-30 14:23 UTC] felipe@php.net
var_dump($a);

Show:
array(2) {
  [0]=>
  int(1)
  [2]=>
  int(3)
}

Hence, it isn't a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC