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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 - 16 = ?
Subscribe to this entry?

 
 [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: Tue Mar 19 03:01:29 2024 UTC