M
M
Murat Atila2015-12-19 23:10:22
PHP
Murat Atila, 2015-12-19 23:10:22

Why are empty array elements removed?

Hello everyone, there is such a php script
joxi.ru/MAjpqq7FvjEMOm
I pass the $schedule variable to the function, which contains:
joxi.ru/YmENMM1sZweQO2
joxi.ru/4AkGqq0sMob6nA
At the output I get this json:
joxi.ru/J2b3qqNC40BpZA
Although I expected to get in the form:
joxi.ru/brRYZZEuQ7MeMA
Actually the question is, why are empty array elements removed, and why symbols instead of text?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max QNEI, 2015-12-19
@TheExplay

That's the way it should be. If the array supplied to json_encode contains invalid characters like Cyrillic - json_encode will convert them to UTF-8 .
For json_encode , the second argument can be set to JSON_UNESCAPED_UNICODE - stops encoding multibyte Unicode characters.
From personal practice, I’ll say that on some projects (with which I worked), the entire project used CP1251 (Windows-1251), because of this, json_encode() may not work correctly, and even more so with the JSON_UNESCAPED_UNICODE parameter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question