Skip to content

fix: increment index to detect associative array #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Branlute
Copy link

@Branlute Branlute commented Jul 7, 2023

Hello,

For a patch which remove elements to non associative array, we need to reindex this array.
This line is good

$parent = array_values($parent);

But the condition for $isAssociative has an issue.

We need to increment $i to compare with $index, otherwise $i will always be equal to 0 for all iterations.

@outdooracorn
Copy link
Contributor

We've just stumbled across this as well and came up with a similar fix. Would love to see this merged soon. Pinging @vearutop for visibility.

@outdooracorn
Copy link
Contributor

I decided to create #67 which includes a test case and increments the counter in the body of the foreach loop as I believe that to be easier to read.

@Branlute Branlute closed this Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants