Convert Json to Array Php Online

This is a useful tool to help you convert json object to array in php. It overcomes the inherent disadvantages of the var_export function, helping you to get a beautified php array.

Input Json:


Output PHP

How to convert JSON object to Array Php?

To convert json to php array you can use json_decode($json_content,1) then combine with var_export to get php variable which is an array.

This way is also quite common used to cache php as a variable containing static data.

However, to use it in the source code when hard code is needed for maintenance and bug fixing, it doesn't seem very nice.

Because of:

  • It outputs arrays as array notation(), instead of short [] notation.
  • It outputs arrays of numbers with the explicit and unnecessary 0 => ... key => value syntax.

With the tool to convert json content to php array will overcome the above disadvantages of var_export.

What can you do with the json object to php array converter?

  • You just need to enter the json content by copying and pasting.
  • The tool also supports you to select json files and upload them, then convert to php array.
  • Or you can also select json content from Url.
  • The tool also supports you to download the php file containing the array after converting