|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72232 json_decode(json_encode(…), false) makes numeric indices inaccessible
Submitted: 2016-05-17 17:01 UTC Modified: 2016-05-18 11:16 UTC
From: ggreen at mailw dot com Assigned: cmb (profile)
Status: Duplicate Package: json (PECL)
PHP Version: 7.0.6 OS: Mac OS X
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:
Solve the problem:
39 + 23 = ?
Subscribe to this entry?

 [2016-05-17 17:01 UTC] ggreen at mailw dot com
A json encoded/decoded array is converted back to an array and array_key_exists cannot find the key.

Test script:
	$arry = [100 => 'Fe', 200 => 'Fi', 300 => 'Fo', 400 => 'Fum'];

	print(array_key_exists(100, $arry) ? '-FOUND' : '-LOST');
	print "\n";

	$obj = json_decode(json_encode($arry));


	print(array_key_exists(100, (array)$obj) ? '-FOUND' : '-LOST');
	print "\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-18 11:16 UTC]
-Summary: See code sample +Summary: json_decode(json_encode(…), false) makes numeric indices inaccessible -Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2016-05-18 11:16 UTC]
This is a duplicate of bug #70925.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Aug 02 04:01:24 2021 UTC