Skip to content

mduk/dot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dot

Just a little something to make working with config arrays easier.

Example

$config = [
  'a' => [
    'b' => [
      'c' => [
        'd' => 'e!'
      ]
    ]
  ]
];

$dot = new Mduk\Dot( $config );

// Fetch a particular key
$dot->get( 'a.b.c.d' ); // 'e!'

// Set a key with dot notation
$dot->set( 'a.b.c.e', 'f!' );

// Fetch a key further up to get lower keys as a deep array
$dot->get( 'a.b.c' ); // [ 'd' => 'e!', 'e' => 'f!' ]

// Creating child keys of a key will overwrite any previously set value
$dot->set( 'a.b.c.d.e', 'g?' );

$dot->get( 'a.b.c' ); // [ 'd' => [ 'e' => 'g?' ], 'e' => 'f!' ]

About

Handy helper for working with config trees.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages