Bug #75423 [Opn->Dup]: Isset not work on array with stdClasses
| From: | requinix@php.net | Date: | Tue, 24 Oct 2017 09:21:06 +0000 |
| Subject: | Bug #75423 [Opn->Dup]: Isset not work on array with stdClasses | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212259@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75423&edit=1
ID: 75423
Updated by: requinix@php.net
Reported by: rynkiewiczm at gmail dot com
Summary: Isset not work on array with stdClasses
-Status: Open
+Status: Duplicate
Type: Bug
Package: Arrays related
PHP Version: 7.1.10
Block user comment: N
Private report: N
New Comment:
If I had a nickel...
This has been fixed in 7.2.
https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts
Previous Comments:
------------------------------------------------------------------------
[2017-10-24 09:05:37] rynkiewiczm at gmail dot com
Description:
------------
When you convert array from stdClass you will get array with many stdClasses.
Isset on index of array element will not work correctly if you try it.
Test script:
---------------
$id = '11400';
$json =
'{"11400":{"test":"1","test":"2","xyz":"abc"}}';
// yes, I know second parametr, but it should work too
$decodedJson = (array)json_decode($json);
if (isset($decodedJson[$id])) {
echo 'exists!';
} else {
echo 'not exists!';
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75423&edit=1