First off, it's worth pointing out that PHP is not "messing up" anything. It's escaping characters, which may look weird, but it is perfectly valid and when you json_decode it later it will be just the same as it was originally. See here: https://3v4l.org/Smj2F

If you don't like the escaping though, you can use the JSON_UNESCAPED_UNICODE flag:

https://www.php.net/function.json-encode

This flag will "encode multibyte Unicode characters literally" according to https://www.php.net/manual/en/json.constants.php.

So you can do:

json_encode($array, JSON_UNESCAPED_UNICODE);

And it will give you the following output:

["M-am întîlnit ieri cu","fosta mea profă de matematică"]

Working example: https://3v4l.org/daETG

Answer from jszobody on Stack Overflow
🌐
PHP
php.net › manual › en › function.json-encode.php
PHP: json_encode - Manual
Returns a JSON encoded string on success or false on failure. ... <?php $a = array('<foo>',"'bar'",'"baz"','&blong&', "\xc3\xa9"); echo "Normal: ", json_encode($a), "\n"; echo "Tags: ", json_encode($a, JSON_HEX_TAG), "\n"; echo "Apos: ", json_encode($a, JSON_HEX_APOS), "\n"; echo "Quot: ", json_encode($a, JSON_HEX_QUOT), "\n"; echo "Amp: ", json_encode($a, JSON_HEX_AMP), "\n"; echo "Unicode: ", json_encode($a, JSON_UNESCAPED_UNICODE), "\n"; echo "All: ", json_encode($a, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE), "\n\n"; $b = array(); echo "Empty arra
🌐
W3Schools
w3schools.com › js › js_json_php.asp
JSON PHP
Before you send the request to the server, convert the JSON object into a string and send it as a parameter to the url of the PHP page: Use JSON.stringify() to convert the JavaScript object into JSON:
🌐
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
Like JSON.parse, JSON.stringify ... JSON.stringify as well. You can combine the methods above to create powerful, dynamic implementations on your website or application. Let’s say you want to get information from a database, safely return the data as JSON, and loop through it dynamically, you can do so with a bit of PHP and JavaScript ...
Find elsewhere
🌐
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 - This approach involves using the explode() function to split a string into an array based on a delimiter and then converting that array into an associative array before using json_encode() to create the JSON object.
🌐
Online Tools
onlinetools.com › json › stringify-json
Stringify JSON – Online JSON Tools
Create a JSON data structure from a PHP data structure. ... Diff JSON files and show differences visually. ... Lexicographically sort the order of JSON object keys. ... Exchange keys with values in a JSON file. ... Create a JSON array with random values.
🌐
ReqBin
reqbin.com › code › php › 0uwqq41y › json-to-array-php-example
How do I convert JSON to PHP array?
To convert a JSON data string to a PHP array, you can use the json_decode($json) function. The json_decode() function accepts the JSON string as the first parameter and a few additional parameters to control the process of converting JSON to ...
🌐
ReqBin
reqbin.com › code › php › 0kvtdskv › php-array-to-json-example
How do I convert PHP Array to JSON?
To convert a PHP array to JSON data string, you can use the json_encode($value, $flags, $depth) function. The json_encode() function takes a PHP array as input and returns a JSON string representation.
🌐
Alessio Puppi's Blog
alessiopuppi.blog › home › home › json › json in javascript & php: parse and stringify json
JSON in JavaScript & PHP: Parse and Stringify JSON
May 26, 2024 - The JSON.stringify() method converts a JavaScript object or value to a JSON string. An optional replacer function can be provided to filter or transform the properties of the object before the string is returned, and an optional space argument ...
🌐
W3Schools
w3schools.com › js › js_json_stringify.asp
JSON.stringify()
JSON.stringify() can not only convert objects and arrays into JSON strings, it can convert any JavaScript value into a string.
🌐
Dyn-web
dyn-web.com › tutorials › php-js › json › array.php
Pass PHP Arrays to JSON and JavaScript Using json_encode
A JSON_PRETTY_PRINT option[1] can be used to format the JSON output. It is demonstrated in the associative array example below. This example demonstrates passing a numerically indexed PHP array consisting of string, numeric, boolean, and null values to json_encode.
🌐
Envato Tuts+
code.tutsplus.com › home › cloud & hosting
How to Parse JSON in PHP | Envato Tuts+
May 31, 2021 - However, once we convert it into ... turn your own data into a well-formatted JSON string in PHP with the help of the json_encode() function....