php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64866 Example is incorrect
Submitted: 2013-05-17 09:01 UTC Modified: 2013-05-17 20:18 UTC
From: gater89 at web dot de Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS:
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: gater89 at web dot de
New email:
PHP Version: OS:

 

 [2013-05-17 09:01 UTC] gater89 at web dot de
Description:
------------
---
From manual page: http://www.php.net/function.json-encode#refsect1-function.json-encode-examples
---



Test script:
---------------
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);

echo json_encode($arr);
?>
Output:
{"a":1,"b":2,"c":3,"d":4,"e":5}

is wrong

["a":1,"b":2,"c":3,"d":4,"e":5]
this is correct


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-17 20:18 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2013-05-17 20:18 UTC] aharvey@php.net
The example's correct: JSON uses curly braces for objects (PHP associative arrays). Test case: http://3v4l.org/pMBmv
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC