| @@ 232-239 (lines=8) @@ | ||
| 229 | * @param string $string |
|
| 230 | * @return array |
|
| 231 | */ |
|
| 232 | function match() { |
|
| 233 | $match = function($pattern, $string) { |
|
| 234 | $results = []; |
|
| 235 | preg_match_all($pattern, $string, $results); |
|
| 236 | return $results[0]; |
|
| 237 | }; |
|
| 238 | return apply(curry($match), func_get_args()); |
|
| 239 | } |
|
| 240 | ||
| 241 | /** |
|
| 242 | * Curried version of `substr_count` with changed order of parameters, |
|
| @@ 106-114 (lines=9) @@ | ||
| 103 | * @param array $list |
|
| 104 | * @return array |
|
| 105 | */ |
|
| 106 | function each() { |
|
| 107 | $each = function($fn, $list){ |
|
| 108 | foreach ($list as $item) { |
|
| 109 | apply($fn, [$item]); |
|
| 110 | } |
|
| 111 | return $list; |
|
| 112 | }; |
|
| 113 | return apply(curry($each), func_get_args()); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Returns the first item of the given array or string. |
|