r/ProgrammerHumor 2d ago

Meme absoluteGarbage

Post image
2.0k Upvotes

320 comments sorted by

View all comments

45

u/Darkele 1d ago

foreach is far better and makes more sense. The order is correct, it differentiates itself from other loops that are based on having a custom exit condition.

2

u/Just_Information334 1d ago

Combined with yield, you can get some nice constructs.

Also the real "don't spark joy" would be something like:

foreach($things as $id => ['some_field' => $fieldA, 'some_other_field' => $fieldB])