Why json_encode( all of a sudden stopped encoding the php arrays

I discovered why js_encode wasn’t working. It was because of the Hebrew columns in the db table. I had defined the charset:

header("Content-Type: text/html; charset=utf-8");
define("DSN", "mysql:host=localhost; dbname=".$db."; charset=utf8");
define("USERNAME", "root");
define("PASSWORD", "");

But even though these were defined it still didn’t work.

Then I opened xampp/mysql/bin/my.ini and changed:

#collation_server=utf8_unicode_ci
#character_set_server=utf8

to

#character-set-server  = utf8mb4
#collation-server      = utf8mb4_general_ci

It works (now due to the big info the browser keeps crashing). I wonder if there was an easier way instead of changing my.ini?