4 ms·
My biggest PHP pet peeve has always been that the arguments are switched in the array_map and array_filter functions. array_map takes the callback first while a
by 65 3y ago
My biggest PHP pet peeve has always been that the arguments are switched in the array_map and array_filter functions. array_map takes the callback first while array_filter takes the array first.
I understand that array_filter takes the array first so you don't have to pass a callback if you just want to filter out empty values, but they could have designed these functions more consistently.
I forget which argument comes first when using these functions all the time.
- willio58 3y agoYeah sometimes the little details can make or break a language or at least its popularity
- yurishimo 3y agoHonestly, this is why I use some version of the “Collection” class that is popular in most frameworks. Normalization for array and string functions is huge for reducing some cognitive load. Would it be nice if this was built in? Of course, but until then, I’ll take all the help I can get.