3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Placeholder{} function curry(callable $func, ... $curriedArgs) { return function(...$fulfillment) use ($func, $curriedArgs) { return $func(...array_merge(array_map(function($arg) use ($fulfillment) { if ($arg instanceof Placeholder) return array_shift($fulfillment); return $arg; }, $curriedArgs), $fulfillment)); }; }; $resultset = json_decode('[{ "id": 1, "gender": "Male", "name": "Matthew" }, { "id": 2, "gender": "Male", "name": "Willie" }, { "id": 3, "gender": "Female", "name": "Ann" }, { "id": 4, "gender": "Female", "name": "Margaret" }, { "id": 5, "gender": "Female", "name": "Marie" }]',TRUE); $filterGender = function($row,$gender){ return $row['gender']==$gender; }; $detectMen = curry($filterGender,(new Placeholder),'Male'); $detectWomen = curry($filterGender,(new Placeholder),'Female'); var_dump($detectMen(['gender'=>'Male'])); //works $getLadies = curry('array_filter',(new Placeholder),$detectWomen); var_dump($getLadies($resultset)); //does not work
Output for git.master, git.master_jit, rfc.property-hooks
bool(true) Fatal error: Uncaught TypeError: array_filter(): Argument #3 ($mode) must be of type int, array given in /in/0i5FV:5 Stack trace: #0 /in/0i5FV(5): array_filter(Array, Object(Closure), Array) #1 /in/0i5FV(46): {closure}(Array) #2 {main} thrown in /in/0i5FV on line 5
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
25.19 ms | 405 KiB | 5 Q