devondahon's avatar

Difference between helpers data_set() and data_fill()

What 's the difference between the two helper functions data_set() and data_fill() ?

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

Nothing.

data_fill is an alias for data_set:

// vendor/laravel/framework/src/Illuminate/Collection/helpers.php
function data_fill(&$target, $key, $value)
{
    return data_set($target, $key, $value, false);
}
1 like
Sinnbeck's avatar

Just a snippet from the docs to show what false does in the example by @tykus

By default, any existing values are overwritten. If you wish to only set a value if it doesn't exist, you may pass false as the fourth argument to the function:

1 like

Please or to participate in this conversation.