JSON to PHP array

 

JSON



PHP





Option




This tool allows you to convert json to php array, object or associative array. It allows you to quickly convert your json data into php objects without having to convert them yourself manually. It also avoids embedding json data in your code and having to call the json_decode function.

Note: You can mix array with objects.

A user guide is available below to help you use this converter.

User guide

To convert JSON data:

  • Drag and drop your JSON file or copy / paste your JSON text directly into the editors above.
  • As soon as the editor detects a valid JSON, it displays the php code.
  • In order to download the results you must click on "Download PHP" button.
  • You can also copy the PHP code to the clipboard by clicking on the button "Copy to clipboard".

This tool does not convert php array to json. If you think that having this feature seems interesting to you, do not hesitate to indicate it in the comments.

Above the editors, you can set the options:

  • Convert JSON object to: you have the choice between converting to objects or associative arrays


JSON to PHP converter

PHP is one of the most used languages even if it does not have the best reputation (you can write clean, fast and maintainable code in PHP ... It is not a legend :) ).

PHP arrays are essential for storing, managing, and operating on sets of variables. In the PHP language, there are many functions for manipulating arrays, which makes manipulating them quick and easy. Therefore, they are often used. PHP objects are also used to store data. You are given the choice between converting to an array or to an object.

JSON is a popular format that uses human-readable text. JSON is a syntax for serializing objects, arrays, numbers, strings, booleans, and null. I prefer it to XML format (Everyone has his opinion).

PHP is a language which allows quite easily to manipulate data. Since JSON format is used a lot, chances are some people need to convert JSON data in order to use it in their PHP code. In PHP language, it is possible to use the json_decode function to convert JSON code to a PHP object / array. But it might be useful for someone to have their JSON data directly in their code without conversion (Performances ...).
I do not know what the use cases are, but if you come across this page it must be useful for something :)

If you think of interesting features (or you find a bug), which could be useful to other people, do not hesitate to add a comment to present them. The same if you detect a bug.



You can report a bug or give feedback by adding a comment (below) or by clicking "Contact me" link (at the top right hand corner of the page).

Comments