Bug #69601 [Opn->Nab]: Miss array key access after json_decode

From: Date: Fri, 08 May 2015 11:18:16 +0000
Subject: Bug #69601 [Opn->Nab]: Miss array key access after json_decode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192580@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69601&edit=1 ID: 69601 Updated by: cmb@php.net Reported by: turin dot tomsk at gmail dot com Summary: Miss array key access after json_decode -Status: Open +Status: Not a bug Type: Bug Package: JSON related Operating System: Linux PHP Version: 5.5.24 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Read the section on "Converting to array" in the manual[1]. What you actually want to do is $q = json_decode($s, true); [1] <http://php.net/manual/en/language.types.array.php#language.types.array.casting> Previous Comments: ------------------------------------------------------------------------ [2015-05-08 10:07:26] turin dot tomsk at gmail dot com Description: ------------ When json_encode array and json_decode it, can't get access to array key of object and generate PHP Notice. Test script: --------------- <?php $a = [1 => 2]; $s = json_encode($a); $b = @json_decode($s); $q = (array)$b; var_dump($q[1]); // PHP Notice: Undefined offset: 1 in php shell code on line 1 ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69601&edit=1

« previous php.bugs (#192580) next »