Replies: 1 comment
-
this is because some callback need to get $this->items keys, by default callback can only get the value |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
the office source code (https://github.com/laravel/framework/blob/8.x/src/Illuminate/Collections/Collection.php)
/**
* Run a map over each of the items.
*
* @param callable $callback
* @return static
*/
public function map(callable $callback)
{
$keys = array_keys($this->items);
i think the below code can achieve the same result and i have tried many times:
array_map does not change $this->items keys, so what is the purpose of this design?
Beta Was this translation helpful? Give feedback.
All reactions