kozz / array-updater
Library allows easily update multidimensional arrays
Installs: 5 136
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- phpoption/phpoption: *
Requires (Dev)
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: dev-master
Suggests
- php: >=5.5.16
This package is not auto-updated.
Last update: 2024-12-17 03:30:28 UTC
README
Recursive Array Updater
Update One
$source = ['this' => ['is' => ['the' => ['path' => [ 1,2,3,4,5 ]]]]]; $array = ArrayUpdater::from($source) ->node('this')->node('is')->node('the')->node('path')->all() ->replace(1, 100); /** * $array = ['this' => ['is' => ['the' => ['path' => [ * 100,2,3,4,5 * ]]]]]; */
Update Multiple
$source = ['this' => [ ['the' => ['path' => [ 1,2,3,4,5 ]]], ['the' => ['path' => [ 1,2,3,4,5 ]]] ]]; $array = ArrayUpdater::from($array) ->node('this')->all()->node('the')->node('path')->all() ->replaceAssoc([1=>100, 3=>300]); /** * * $array = ['this' => [ * ['the' => ['path' => [ * 100,2,300,4,5 * ]]], * ['the' => ['path' => [ * 100,2,300,4,5 * ]]] * ]]; */ *