Skip to content

leNEKO/flattener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6c0053a · Apr 28, 2024

History

5 Commits
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024
Apr 28, 2024

Repository files navigation

Flattener

A lib for (un)flatten php data structure and a small cli for apply this on Json input.

Usage

Lib

Basically, Flattener::flatten(...) turn this

<?php

[
  'hello' => [
    'world' => [
      '!', '?'
    ],
    'people' => [
      1, 2.3 
    ],
  ],
  'bye' => null
]

into

<?php 

[
  '.hello.world[0]' => '!',
  '.hello.world[1]' => '?',
  '.hello.people[0]' => 1,
  '.hello.people[1]' => 2.3,
  '.bye' => null,
]

(And Flattener::unflatten(...) will play this backward)

CLI

Get help

bin/json-flatten --help

Dev

Coverage

make coverage