osushi / jsobj2php
Convert into php array from javascript object
0.0.3
2018-02-10 20:44 UTC
Requires
- php: >=7.0.0
Requires (Dev)
- phpunit/phpunit: 6.4.*
This package is auto-updated.
Last update: 2025-03-08 18:20:59 UTC
README
Functions
- Convert into php array from javascript object
Requirements
- PHP >= 7.0.*
Usage
composer require osushi/jsobj2php
Examples
See: https://github.com/Osushi/jsobj2php/blob/master/example.php
<?php require_once 'vendor/autoload.php'; use JsObj2Php\Converter; $str = '{ baseprice:3300, items:[{id:1,price:1000,commnet:"foo",memo:[]},{id:2,price:2000,memo:[]}], counts:[10, 20], message:"ほげ", pickup:{id:1,price:1000,commnet:"foo",memo:[0, 1, 2]} }'; var_export(Converter::execute($str, true)); // If here sets `Converter::execute($str)`, you can get stdClass object. /* array ( 'baseprice' => 3300, 'items' => array ( 0 => array ( 'id' => 1, 'price' => 1000, 'commnet' => 'foo', 'memo' => array ( ), ), 1 => array ( 'id' => 2, 'price' => 2000, 'memo' => array ( ), ), ), 'counts' => array ( 0 => 10, 1 => 20, ), 'message' => 'ほげ', 'pickup' => array ( 'id' => 1, 'price' => 1000, 'commnet' => 'foo', 'memo' => array ( 0 => 0, 1 => 1, 2 => 2, ), ), ) */