https://github.com/ellisgl/geeklab-arraytranslation
Convert an array to another data format or convert a data format to an array.
https://github.com/ellisgl/geeklab-arraytranslation
array data format php php7-2 php72
Last synced: 10 months ago
JSON representation
Convert an array to another data format or convert a data format to an array.
- Host: GitHub
- URL: https://github.com/ellisgl/geeklab-arraytranslation
- Owner: ellisgl
- License: bsd-2-clause
- Created: 2018-07-31T11:29:48.000Z (over 7 years ago)
- Default Branch: release
- Last Pushed: 2023-04-20T19:05:37.000Z (almost 3 years ago)
- Last Synced: 2025-03-25T05:43:43.632Z (10 months ago)
- Topics: array, data, format, php, php7-2, php72
- Language: PHP
- Homepage:
- Size: 177 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.BSD
Awesome Lists containing this project
README
[](https://travis-ci.com/ellisgl/GeekLab-ArrayTranslation)
# GeekLab-ArrayTranslation
Convert an array to another data format or convert a data format to an array.
## Supports:
* JSON
* XML
* PHP internal session serialized data
* PHP internal binary serialized data
* PHP Serialized() data
* YAML
## Todo:
* WDDX support
* igbinary support
## Installation:
composer require geeklab/arraytranslation
## Usage:
encode(array('a' => 'x', 'b' => y', 'c' => 'z');
## API:
### \GeekLab\ArrayTranslation::create(string $type, string $handler): object
#### Description:
This is the factory to return the class for array<->data type translation.
`$type` can be set to xml, json, yaml, php, php_binary or php_binary for now.
`$handler` is for pointing to a customer handler. Must implement GeekLab\ArrayTranslation\TranslationInterface
#### Usage:
`$at = \GeekLab\ArrayTranslation::create('json');`
### \GeekLab\ArrayTranslation::encode(array $arr): string
### Description:
This method will convert an array to the type the object was created with.
### Usage:
`$x = $at->encode(array('a', 'b', 'c'));`
### \GeekLab\ArrayTranslation::encode(string $str): array
### Description:
This method will convert a string (data type) to an array.
### Usage:
`$y = $at->decode('["a","b","c"]');`