|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78529 Internal Array Pointer still points to NULL after adding element
Submitted: 2019-09-12 15:35 UTC Modified: 2019-09-12 16:07 UTC
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: philipp at atelierdisko dot de Assigned:
Status: Open Package: Arrays related
PHP Version: 7.3.9 OS: Linux & Darwin
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-09-12 15:35 UTC] philipp at atelierdisko dot de
This problem occurs in Version 7.3.0 - 7.40beta4.

Steps to reproduce:
1. Have an array $a with elements and integer keys
2. Let the internal pointer point beyond the end of the elements list using next($a)
3. Set a value by key where key is lower then the lowest existing key in $a
4. Call key($a)

I expect key($a) to return the key of the element I just added (like it did before 7.3.0), but it returns null.

I have prepared a 3v4l script that shows the problem:

Thanks for having a look at this. I can provide more context if needed.

Test script:
$data = [1 => true];
$data[0] = true;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-12 16:07 UTC]
Is this documented behavior?
 [2019-09-12 16:55 UTC] philipp at atelierdisko dot de
I was looking for hints to this in the following places:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 13:01:32 2024 UTC