leneko/flattener

(un)flatten php/json data structure

v1.0.1 2024-04-28 14:49 UTC

This package is auto-updated.

Last update: 2024-04-28 16:41:28 UTC


README

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