Skip to content

riyunoa/js-object-to-php-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsObjectToPhpArray

Convert Javascript object to a string in PHP array format

Usage

import { jsObjectToPhpArray } from 'js-object-to-php-array';

let obj = {
    items: [
        {
            cat: 'meow'
        },
        {
            dog: 'woof'
        }
    ]
};

console.log(jsObjectToPhpArray(obj));

Example input and output

Input (Javascript object)

{
    items: [
        {
            cat: 'meow'
        },
        {
            dog: 'woof'
        }
    ]
};

Output

[
    'items' => [
        [
            'cat' => 'meow'
        ],
        [
            'dog' => 'woof'
        ]
    ]
]

Making changes to the source

npm run build

About

Convert JS object to PHP array

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published