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
🌐
GitHub
gist.github.com › merin83 › c0460e90335a8d91ce4894bd0776a8d2
Decode JSON.stringify(object) in php · GitHub
Decode JSON.stringify(object) in php · Raw · .php · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
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 ...
🌐
PHPpot
phppot.com › php › json-handling-with-php-how-to-encode-write-parse-decode-and-convert
JSON Handling with PHP: How to Encode, Write, Parse, Decode and Convert - PHPpot
A comprehensive guide for JSON handling with PHP that includes example code to read, write, parse, encode, decode and convert JSON data.
Find elsewhere
🌐
W3Schools
w3schools.com › js › js_json_stringify.asp
JSON.stringify()
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... A common use of JSON is to exchange data to/from a web server. When sending data to a web server, the data has to be a string. You can convert any JavaScript datatype into a string with JSON.stringify().
🌐
PHP
php.net › manual › en › function.json-encode.php
PHP: json_encode - Manual
It re-indexes the array with consecutive numerical keys (0, 1, 2, ...), ensuring that the JSON output is always a well-formed array. Example: ---------- <?php // Use Case: Filtering a list and ensuring consistent JSON array output // Imagine you have a list of items and need to send a filtered version to a JavaScript frontend // using JSON.
🌐
Online Tools
onlinetools.com › json › stringify-json
Stringify JSON – Online JSON Tools
In this example, we apply the JSON.stringify() function to a text quote by Pythagoras.
🌐
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 - In this example, the JSON string $jsonString is decoded into a PHP associative array $data . The properties of the array can be accessed using the array syntax. JSON is an essential format for data interchange, widely used in web development ...
🌐
4D
developer.4d.com › 4d language › commands by theme › json › json stringify
JSON Stringify | 4D Docs
$vc:=JSON Stringify("Eureka!") // "Eureka!" $vel:=JSON Stringify(120) // "120" $vh:=JSON Stringify(?20:00:00?) // "72000" seconds since midnight SET DATABASE PARAMETER(Times inside objects;Times in milliseconds) $vhms:=JSON Stringify(?20:00:00?) // "72000000" milliseconds since midnight $vd:=JSON ...
🌐
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 - Given a String, the task is to convert the given string into a JSON object in PHP. JSON (JavaScript Object Notation) is a widely used data interchange format.
🌐
Envato Tuts+
code.tutsplus.com › home › cloud & hosting
How to Parse JSON in PHP | Envato Tuts+
May 31, 2021 - Here is a very basic example: In this tutorial, you learned how to read JSON data from a file or string in PHP. You also learned how to convert that JSON into an array and traverse it to extract the information you want. You should now be able to get information from JSON in a file where you don't know all the keys in key-value pairs. In the last two sections, we covered how you can stringify ...
🌐
Scout APM
scoutapm.com › blog › php-json-encode-serialize-php-objects-to-json
PHP Json_encode: Serialize PHP Objects to JSON
In this post, we’ll learn about the JSON format, about the json_encode() function - what it is, why it is required, and how it can be used to convert PHP data structures into JSON format, all with examples. In the end, we’ll also see how we can decode JSON data to be able to process it.