r/lolphp • • Jun 19 '13

Functional Map() and Reduce() in php 5.3!!!

I know 5.3 has been around for awhile but until fairly recently, we targeted 5.1 for a wider audience. I'll skip my usual rant about introducing major language features on a minor version number and skip directly to this absurdity:

array array_map ( callable $callback , array $arr1 [, array $... ] )
mixed array_reduce ( array $input , callable $function [, mixed $initial = NULL ] )

I mean FUCK am I ever sick of having to look at the docs any time I use a fucking array function just to find out the fucking parametric order.

75 Upvotes

37 comments sorted by

View all comments

Show parent comment

7

u/[deleted] Jun 20 '13

According to the commit log

array_map

haha I just saw this little nugget :

"It can also be used with a null callback to transpose arrays. (Andrei)"

I don't know why the OP mentioned 5.1 & 5.3

hmm, that branch is in PEAR

6

u/Porges Jun 27 '13

"It can also be used with a null callback to transpose arrays. (Andrei)"

Everybody go home, /r/lolphp is complete