Open ktalebian opened 10 years ago
I do not think this is a great idea, as you're now getting a combination of implementation details inside the each method, which I don't think is necessary. The first approach is much nicer and cleaner (aka, as is).
You could use:
Arrays::each(Arrays::get(Input::all(), 'shifts', []), function($shift) { ... });
When looping through an array, I always check to ensure the array key exists before calling
Arrays::each
.Example: say I get a POST request that sometimes contains
Input::get('shifts')
. Ifshift
exists, I then want to loop through. Currently, I doImplementing Laravel's
array_get()
and checking forfalse
values insideArrays::each
would allow to shorten the above toand the function
Arrays::each($array, Closure $closure)
can becomeWhat do you think?