Laravel

Laravel Miscellaneous Helper Function: data_fill

Author

John Koster

Published on November 21, 2016

data_fill(&$target, $key, $value)

The data_fill helper function accomplishes the same fundamental task as the data_set helper function. The only difference is that the data_fill does not define an optional $overwrite parameter. data_fill internally makes a call to the data_set (discussed in the Laravel Miscellaneous Helper Function: data_set article) helper function with $overwrite set to false. This function does not overwrite data.

The following function calls are equivalent wand would produce the same results:

1<?php
2 
3// Create a object to work with.
4$testObject = new stdClass;
5 
6// Set data using `data_fill`.
7data_fill($testObject, 'name', 'Jane');
8 
9// Set data using `data_set`.
10data_set($testObject, 'name', 'Jane', false);

Explore The Blog