Skip to content

Updated notes for example 10 in arrays page#5578

Open
Narkunan wants to merge 1 commit into
php:masterfrom
Narkunan:Fix-Outdated-note-in-Example-10-on-Types-Arrays-page
Open

Updated notes for example 10 in arrays page#5578
Narkunan wants to merge 1 commit into
php:masterfrom
Narkunan:Fix-Outdated-note-in-Example-10-on-Types-Arrays-page

Conversation

@Narkunan
Copy link
Copy Markdown
Contributor

Fix: #4788

Comment thread language/types/array.xml
As mentioned above, if no key is specified, PHP uses the next integer key: the
maximum existing integer index + <literal>1</literal>. If the array currently has no integer
indices, the key will be <literal>0</literal> (zero). For the historical behaviour prior to
<literal>PHP 8.3.0</literal> — where appending after a negative key could yield <literal>0</literal> — see Example #7.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is PHP a literal value?

Copy link
Copy Markdown
Member

@jordikroon jordikroon May 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't mention PHP at all. It falls under the same category as using "you". Instead I prefer to use the following type of phrasing. As Kamil also suggested.

As mentioned above, if no key is specified, the next integer key will be used: the maximum existing integer index + 1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct, but also the old "as mentioned above" is super ambiguous.

@kamil-tekiela
Copy link
Copy Markdown
Member

Was this written with AI?

Comment thread language/types/array.xml
Comment on lines +537 to +540
As mentioned above, if no key is specified, PHP uses the next integer key: the
maximum existing integer index + <literal>1</literal>. If the array currently has no integer
indices, the key will be <literal>0</literal> (zero). For the historical behaviour prior to
<literal>PHP 8.3.0</literal> — where appending after a negative key could yield <literal>0</literal> — see Example #7.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
As mentioned above, if no key is specified, PHP uses the next integer key: the
maximum existing integer index + <literal>1</literal>. If the array currently has no integer
indices, the key will be <literal>0</literal> (zero). For the historical behaviour prior to
<literal>PHP 8.3.0</literal> — where appending after a negative key could yield <literal>0</literal> — see Example #7.
If no key is specified, the key will be the
maximum existing integer index + <literal>1</literal>. If the array has no positive
integer indices, the key will be <literal>0</literal>.
As of PHP 8.3.0, it can also be a negative integer.

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.

Outdated note in Example \#10 on Types > Arrays page

3 participants