Easy peasy lemon squeezy: http://www.php.net/manual/en/function.json-encode.php

<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);

echo json_encode($arr);
?>

There's a post by andyrusterholz at g-m-a-i-l dot c-o-m on the aforementioned page that can also handle complex nested arrays (if that's your thing).

Answer from David Titarenco on Stack Overflow
🌐
W3Schools
w3schools.com › php › php_json.asp
PHP and JSON
PHP has some built-in functions to handle JSON. First, we will look at the following two functions: ... The json_encode() function is used to encode a value to JSON format. This example shows how to encode an associative array into a JSON object:
Discussions

Getting contents of a JSON array into PHP as part of a $_POST array
I am working on trying to increase my JavaScript skills beyond the beginner level, and decided to try to figure out how to add a feature to a recipe application that I built using PHP/mySQL. It involves dynamically adding input boxes for ingredients and textareas for directions to the Add Recipe ... More on sitepoint.com
🌐 sitepoint.com
0
August 23, 2018
Get Value of JSON Array
Hi, I've been reading a lot of tutorials from other sites on how to get a value from a JSON array but none of them seem to work for me. I have the below JSON I'm trying to get the value of OrderNumber and place it within its own variable. But all the tutorials I've read don't have the [ at the be... More on forums.phpfreaks.com
🌐 forums.phpfreaks.com
4
July 19, 2022
update json array in mysql not working php
Shouldn’t $_GET[‘replyID’] and $images be flipped in the bind param? More on reddit.com
🌐 r/PHPhelp
8
1
February 12, 2020
[HELP] json_decode on PHP fails to convert an array of JSON objects
can you C/P error. I don't know why are you using json_decode. Can you try without json_decode?. Sample::insert($samples); More on reddit.com
🌐 r/laravel
9
0
December 14, 2016
🌐
IBM
ibm.com › docs › en › integration-bus › 9.0.0
Using PHP arrays with JSON
We cannot provide a description for this page right now
🌐
Quora
quora.com › How-do-I-make-a-JSON-array-in-PHP
How to make a JSON array in PHP - Quora
I assume you want to pass the array back to the front end so it can process the data. 1: The hard way You can hand-code it. A json-encoded array is just a string. [code ]$myJsonArray = "{'name':'Cal Evans','occupation':'ElePHPant'}...
🌐
Elastic
elastic.co › elastic docs › reference › elasticsearch › clients › php › configuration › dealing with json arrays and objects in php
Dealing with JSON arrays and objects in PHP | PHP
By using an explicit stdClass object, we can force the json_encode parser to correctly output an empty object, instead of an empty array. This verbose solution is the only way to acomplish the goal in PHP…
🌐
Scaler
scaler.com › home › topics › php-tutorial › how to create json objects in php
How to Create JSON Objects in PHP - Scaler Topics
April 14, 2024 - In this example, $multiArray is a multidimensional array representing information about a person and a company. The json_encode() function transforms this structure into a JSON-formatted string, ready for various use cases like data exchange or storage. JSON data manipulation in PHP involves tasks such as decoding JSON strings, accessing and modifying data within resulting PHP objects or arrays, and encoding data back to JSON.
Find elsewhere
🌐
SourceBae
sourcebae.com › home › how do i make a json array in php?
How do I Make a JSON Array in PHP? - SourceBae
August 21, 2025 - This allows you to access and manipulate the JSON data within your PHP script effortlessly. Yes, you can create nested JSON arrays in PHP. Simply define multidimensional arrays in PHP and use json_encode() to convert them into nested JSON structures.
🌐
PHPpot
phppot.com › php › php-object-to-array
PHP Object to Array Convert using JSON Decode - PHPpot
April 4, 2024 - This quick example performs a PHP object to array conversion in a single step. It creates an object bundle and sets the properties. It uses JSON encode() decode() function for the conversion.
🌐
SitePoint
sitepoint.com › javascript
Getting contents of a JSON array into PHP as part of a $_POST array
August 23, 2018 - I am working on trying to increase my JavaScript skills beyond the beginner level, and decided to try to figure out how to add a feature to a recipe application that I built using PHP/mySQL. It involves dynamically addin…
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-encode-array-in-json-php
How to Encode Array in JSON PHP ? - GeeksforGeeks
July 23, 2025 - PHP provides a built-in function json_encode() to encode PHP data structures, including arrays, into JSON format.
🌐
PHP Freaks
forums.phpfreaks.com › php coding › php coding help
Get Value of JSON Array - PHP Coding Help - PHP Freaks
July 19, 2022 - Hi, I've been reading a lot of tutorials from other sites on how to get a value from a JSON array but none of them seem to work for me. I have the below JSON I'm trying to get the value of OrderNumber and place it within its own variable. But all the tutorials I've read don't have the [ at the be...
🌐
Edureka Community
edureka.co › home › community › categories › web development › php › php array to json array using json encode
PHP Array to JSON Array using json encode | Edureka Community
June 12, 2022 - I have encoded an Array I've made using the inbuilt json_encode(); function. I need it ... remove these row numbers without using any Regex trickery?
🌐
JSON Formatter
jsonformatter.org › json-parser
JSON Parser Online to parse JSON
JSON Example with all data types including JSON Array. Python Pretty Print JSON · Read JSON File Using Python · Validate JSON using PHP · Python Load Json From File · JSON.Parse() is javascript method for parsing JSON which converts to JavaScript objects.
🌐
Scaler
scaler.com › home › topics › php-tutorial › json with php
JSON with PHP - Scaler Topics
March 31, 2024 - You can then access the individual data elements using array or object notation in PHP. Additionally, the json_decode() function supports optional parameters that allow you to control the decoding behavior, such as specifying whether the JSON should be decoded as an associative array or an object.
🌐
Empty Code
emptycode.in › home › json string to php array/object
JSON to Array PHP: Convert PHP Array to JSON
December 25, 2023 - Converting JSON String to PHP Array can be done by using the json_decode() function. By default, it returns an object.
🌐
Tutorials Class
tutorialsclass.com › home › tools › code tools › code conversion tools › json to php array convertor
JSON to PHP Array Converter online
November 30, 2025 - Free JSON to PHP Array converter. Easily convert JSON to well-formatted PHP array code online with syntax highlighting and clean structure.
🌐
JSON Formatter
jsonformatter.curiousconcept.com
JSON Formatter & Validator
Added autofocus to JSON Data input. Fixed stripping of invisible characters. Thanks Paul. Fixed a typo. Thanks Anonymous. Added a donation button. Fixed a number validation bug. Thanks Chris and Anonymous. Updated external libraries. Improved caching. Added ability to collapse/expand objects and arrays.
🌐
Chrome Web Store
chromewebstore.google.com › detail › json-formatter › bcjindcccaagfpapjjmafapmmgkkhgoa
JSON Formatter - Chrome Web Store
It's a browser and editor for JSON document.You can get a beautiful view. And transcoding Unicode Base64 URL with decode & encode. PHPView4.3 · Average rating 4.3 out of 5 stars. Learn more about results and reviews. Validate and view PHP print_r outputs · Redux DevTools4.6 ·
🌐
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).