Skip to content

urakozz/php-array-updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Array Updater

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version Latest Unstable Version License

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
   *  ]]]
   * ]];
   */
   *

About

Recursive Object-Oriented Array Updater

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages