0
Array
(
[0] => Array
    (
        [ID] => 121175
        [TARIH] => Jul 11 2017 03:39:13:473PM
        [HASTANEADI] => Ö. ANKARA MEDICANA HST.
        [FIELDFORCE] => MELTEM TAŞTAN
        [NOTT] =>  
        [RAKIPFIRMA] => EVET
        [FIRMAADI] => CANBEBE ,BEPANTHOL
    )

[1] => Array
    (
        [ID] => 121156
        [TARIH] => Jul 11 2017 11:56:35:637AM
        [HASTANEADI] => BİLKENT ATATÜRK EĞT.VE ARŞ.HST.
        [FIELDFORCE] => MELTEM TAŞTAN
        [NOTT] => 65 DOĞUM
        [RAKIPFIRMA] => HAYIR
        [FIRMAADI] =>  
    )

[2] => Array
    (
        [ID] => 121149
        [TARIH] => Jul 11 2017 11:40:44:267AM
        [HASTANEADI] => Ö. PENDİK HST.
        [FIELDFORCE] => YEGANE ALBAYRAK
        [NOTT] =>  
        [RAKIPFIRMA] => EVET
        [FIRMAADI] => MOLFİX UNİBABY
    )

[3] => Array
    (
        [ID] => 121130
        [TARIH] => Jul 11 2017 10:34:41:240AM
        [HASTANEADI] => Ö. REMEDY (ÖZKAN) HST.
        [FIELDFORCE] => YEGANE ALBAYRAK
        [NOTT] =>  
        [RAKIPFIRMA] => EVET
        [FIRMAADI] => UNİBABY MUSTELA
    )

[4] => Array
    (
        [ID] => 121078
        [TARIH] => Jul 10 2017 01:39:11:250PM
        [HASTANEADI] => Ö. KORU HST. 12.KAT
        [FIELDFORCE] => MELTEM TAŞTAN
        [NOTT] => 225 DOĞUM
        [RAKIPFIRMA] => HAYIR
        [FIRMAADI] =>  
    )

   )

PHP CODE

 print_r(json_encode($query,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));

That returns NOTHING. But if I reomve json_encode and use just print_r, then it returns that array. I've tried with another queries and it's looks fine actually. I couldn't figure it out guys please help. Thanks!

2 Answers2

0

My recollection is that php's json encode is sensitive to character sets, and in particular enforces the (standard for JSON) that chars are in UTF-8. You may have to re-encode your text into UTF-8 before you encode it.

It is possible that doing this on the serialize() string, then unserializing, then json encode, is the fastest way.

rivimey
  • 921
  • 1
  • 7
  • 24
  • Hi @rivimey Tried this but didn't work. print_r(json_encode(unserialize(serialize($query)),JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT)); – Orhan Bayram Jul 12 '17 at 22:50
  • Sorry, wasn't clear. between unserialize and serialize is a call to translate encodings. Something like: `json_encode(unserialize(mb_convert_encoding(serialize($query). 'UTF-8'),JSON_UNES‌​CAPED_UNICODE|JSON_P‌​RETTY_PRINT))` -- however you may also need to specify the current encoding. – rivimey Jul 13 '17 at 14:19
0

I solved this problem by replacing all non-utf8 chars to utf8 chars.