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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Apr 18 16:01:29 2024 UTC