Multiple Flags for json_encode()

后端 未结 2 2034
隐瞒了意图╮
隐瞒了意图╮ 2020-12-25 12:34

How do I use multiple flags for the php json_encode()-function?

json_encode($array, JSON_PRETTY_PRINT, JSON_UNESCAPED_UNICODE);

This doesn\

相关标签:
2条回答
  • 2020-12-25 12:54

    Those flags are bitmasks. I wrote about it once a long time ago here on SO.

    So, basically, to use more than one option, you need to or them together

    json_encode($array, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
    
    0 讨论(0)
  • 2020-12-25 13:05

    You use a bitmask, as specified in http://php.net/manual/en/function.json-encode.php:

    json_encode($array, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
    

    This will add the binary values of JSON_PRETTY_PRINT and JSON_UNESCAPED_UNICODE with the binary OR operator.

    0 讨论(0)
提交回复
热议问题