Skip to content

Rewrite example on for page - #5752

Open
kamil-tekiela wants to merge 1 commit into
php:masterfrom
kamil-tekiela:Rewrite-for-example
Open

Rewrite example on for page#5752
kamil-tekiela wants to merge 1 commit into
php:masterfrom
kamil-tekiela:Rewrite-for-example

Conversation

@kamil-tekiela

Copy link
Copy Markdown
Member

I saw this example on for page, which appeared to me as misleading. I kept thinking about it all day and I decided that it needs to change. count was used as an example of an expensive operation, which it is not when used with arrays. It can be expensive on objects. What's more important, though, is that the example failed to explain why it's a bad idea to do it this way (it was much worse in the original version years ago). So the example needed modernizing and I took the inspiration from the user note on that page, which is now folded into the new example.

User note: https://www.php.net/manual/en/control-structures.for.php#13463
My explanation on Stack Overflow: https://stackoverflow.com/a/79991793/1839439

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.

1 participant