Skip to content

matejbukovsky/php-array-to-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

php-json-to-array-to-code

Convert JSON object to PHP array or render array as PHP code

Usage

require 'src.php';
$json = '{  
   "hello":"world",
   "properties":{  
      "url":"https://github.com/matejbukovsky/php-json-to-array",
      "convert":true
   },
   "test": ["first", "second", 0]
}';

Return PHP code

echo getCode(json_decode($json, TRUE));

[
    "hello" => "world",
    "properties" => [
        "url" => "https://github.com/matejbukovsky/php-json-to-array",
        "convert" => TRUE,
    ],
    "test" => [
        0 => "first",
        1 => "secons",
        2 => 0,
    ],
];

Try it - Demo

About

Convert JSON object to PHP array

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published