ronappleton / php-key-changer
Format Json string, object and array keys.
Installs: 14
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-11-21 04:58:55 UTC
README
Simple, PhpKeyChanger allows you to pass a json string, object or an array and it will recursively re-key the array using the case you give it.
- Camel Case
- Pascal Case
- Snake Case
- Kebab Case
- Studly Case
Installation
Note: Php key changer requires php ^7.4
composer require ronappleton/php-key-changer
Usage
use RonAppleton\PhpKeyChanger\PhpKeyChanger;
$reKeyed = PhpKeyChanger::reKey($array, 'snake');
You can use any of the above cases, and you can pass in a Json object, a Json string or an Array, it will be return the same type that you pass in.
Credits
I used Illuminate\Support\Str
as the basis of the StringConverters class`, many thanks Taylor Otwell and all contributors.