I have two identical keys in an array.
| From: | Romain Moyne | Date: | Fri, 04 Mar 2022 15:34:16 +0000 |
| Subject: | I have two identical keys in an array. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-327931@lists.php.net to get a copy of this message | ||
Hi,
working with php 8.0.16, i am meeting a hard bug I can't really explain.
One of my script populates an array and doing a var_dump I have that :
Notice the duplicate -1 key. It should not exist as php should erase the
previous key.
array(3) {
[-1]=>
array(1) {
[0]=>
int(10585779)
}
[18]=>
array(2) {
[0]=>
int(10585779)
[1]=>
int(10586274)
}
[-1]=>
array(1) {
[0]=>
int(10586274)
}
}
And when doing a json_encode of that, I get that :
"id_hash":{"-1":[10585779],"18":[10585779,10586274],"-1":[10586274]}
I suspected a utf8 misencoding, but it seems it's not.
Any thoughts?