This should do the trick!

// convert object => json
$json = json_encode($myObject);

// convert json => object
$obj = json_decode($json);

Here's an example

$foo = new StdClass();
$foo->hello = "world";
$foo->bar = "baz";

$json = json_encode($foo);
echo $json;
//=> {"hello":"world","bar":"baz"}

print_r(json_decode($json));
// stdClass Object
// (
//   [hello] => world
//   [bar] => baz
// )

If you want the output as an Array instead of an Object, pass true to json_decode

print_r(json_decode($json, true));
// Array
// (
//   [hello] => world
//   [bar] => baz
// )    

More about json_encode()

See also: json_decode()

Answer from maฤek on Stack Overflow
๐ŸŒ
Jsontophp
jsontophp.com
Convert JSON Object to PHP Array Online
JSON to PHP array converter online - Convert the given JSON object or Array into beautified PHP array that can be used instantly into your PHP file as a PHP array
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ function.json-decode.php
PHP: json_decode - Manual
JSON can be decoded to PHP arrays by using the $associative = true option. Be wary that associative arrays in PHP can be a "list" or "object" when converted to/from JSON, depending on the keys (of absence of them).
Discussions

Converting Object to JSON and JSON to Object in PHP, (library like Gson for Java) - Stack Overflow
I am developing a web application in PHP, I need to transfer many objects from server as JSON string, is there any library existing for PHP to convert object to JSON and JSON String to Objec, like... More on stackoverflow.com
๐ŸŒ stackoverflow.com
A simple tool i wrote to convert your JSON into PHP classes
Emoji breaks it: {"name๐Ÿ˜€":"php","name":"php9.0"} More on reddit.com
๐ŸŒ r/PHP
42
84
November 10, 2021
passing JSON object through PHP
Create php that echos out your data array, use php json_encode. Then in your JavaScript file just make an Ajax request to the php file url More on reddit.com
๐ŸŒ r/PHPhelp
5
0
February 29, 2024
Properly convert JSON with arrays to CSV

Any solution is going to be fragile as you're going from a more expressive to a less expressive format. As long as you can guarantee that all your nested objects (milestone, assignee and author) will always have the same order of elements and will never themselves contain an object or array, you should be able to simply implode them:

Instead of:

foreach ($line['author'] as $value)
{
    array_push($line_array,$value);
}

Use:

array_push($line_array, implode('|', $line['author']));

(Side note: it's generally better to do $myarr[] = 'val'; than array_push($myarr, 'val'). More readable and slightly faster.)

More on reddit.com
๐ŸŒ r/PHPhelp
3
2
April 20, 2015
๐ŸŒ
Site24x7
site24x7.com โ€บ tools โ€บ json-to-php.html
JSON to PHP Converter: Site24x7 Tools
Free tool to generate php code from json object. The attributes in json object are converted into variables in php class.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-convert-a-string-to-json-object-in-php
How to Convert a String to JSON Object in PHP ? - GeeksforGeeks
July 23, 2025 - The json_decode() function is a versatile and commonly used method to convert a JSON-formatted string into a PHP object.
Find elsewhere
๐ŸŒ
ExtendsClass
extendsclass.com โ€บ json-to-php.html
JSON to PHP array
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.
๐ŸŒ
Sling Academy
slingacademy.com โ€บ article โ€บ how-to-convert-json-to-object-in-php-parsing
How to convert JSON to an object in PHP (parsing) - Sling Academy
The json_decode() function is simple to use and involves only a couple of parameters: $jsonObject = json_decode($jsonString); $jsonArray = json_decode($jsonString, true); The first line converts a JSON formatted string, $jsonString, into a PHP object. The second line has an additional parameter, ...
๐ŸŒ
Code Beautify
codebeautify.org โ€บ json-to-php-array-converter
JSON to PHP Array Converter to convert JSON to PHP Array Variable
This tool allows loading the JSON URL, which loads JSON and converts to PHP Array. Click on the URL button, Enter URL and Submit. Users can also convert JSON File to PHP Array by uploading the file.
๐ŸŒ
DEV Community
dev.to โ€บ abgeo โ€บ create-php-object-from-json-content-5bc3
Create PHP Object from JSON Content - DEV Community
May 3, 2020 - '/example.json'); Time for magic! Call composeObject() with the contents of JSON and the main class, and this will give you POPO: $resultObject = $composer->composeObject($jsonContent, Person::class);
๐ŸŒ
Jonathan Suh
jonsuh.com โ€บ blog โ€บ convert-loop-through-json-php-javascript-arrays-objects
Convert and Loop through JSON with PHP and JavaScript Arrays/Objects โ€” Jonathan Suh
September 30, 2014 - The second parameter accepts a boolean that when set as true, tells it to return the objects as associative arrays. You can learn more about the json_decode function from PHPโ€™s documentation.
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ php โ€บ ozcpn0mv โ€บ php-parse-json-example
How do I parse JSON string in PHP?
To parse a JSON string to a PHP object or array, you can use the json_decode($json) function. The json_decode() function recursively converts the passed JSON string into the corresponding PHP objects.
๐ŸŒ
PHPpot
phppot.com โ€บ php โ€บ json-to-array-php
Convert JSON to Array in PHP with Online Demo - PHPpot
This native PHP function decodes the JSON string into a parsable object tree or an array. This is the syntax of this function. json_decode( string $json, ?bool $associative = null, int $depth = 512, int $flags = 0 ): mixed ... $associative โ€“ a boolean based on which the output format varies between an associative array and a stdClass object. ... $flag โ€“ Predefine constants to enable features like exception handling during the JSON to array convert.
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ php โ€บ 4qfsaffq โ€บ php-json-encode-example
How do I encode a PHP object to JSON string?
July 5, 2023 - options (Optional): specifies a bitmask that determines how JSON objects will be converted to PHP objects. The encode function supports the following bitmasks: JSON_FORCE_OBJECT, JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, etc.
๐ŸŒ
JSON Formatter
jsonformatter.net โ€บ home โ€บ json to php array converter
JSON to PHP Array Converter: JSON to PHP Array Online
July 20, 2026 - It allows to download JSON to PHP Array converted data. The JSON to PHP Array converter lets you convert your JSON code and file to PHP Array data output.
๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ php-tutorial โ€บ php-json-parsing.php
How to Encode and Decode JSON Data in PHP - Tutorial Republic
However, an associative array always encoded as object. Decoding JSON data is as simple as encoding it. You can use the PHP json_decode() function to convert the JSON encoded string into appropriate PHP data type.
๐ŸŒ
Quora
quora.com โ€บ How-can-I-convert-a-JSON-string-to-a-PHP-array-or-object
How to convert a JSON string to a PHP array or object - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.