Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON_PRETTY_PRINT and JSON_UNESCAPED_SLASHES in same argument

Tags:

json

php

I am trying to pretty print a json array, AND un-escape slashes at same time, but don't know how...

I've got:

<pre><?php echo json_encode($data, JSON_PRETTY_PRINT); ?></pre>

or

<pre><?php echo json_encode($data, JSON_UNESCAPED_SLASHES); ?></pre>

working fine on their own, but can't seem to combine them.

like image 422
Shawn T Avatar asked Mar 17 '15 04:03

Shawn T


1 Answers

Found out how:

<pre><?php echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); ?></pre>

Read about the PHP bitwise operators.

like image 82
Shawn T Avatar answered Nov 03 '22 11:11

Shawn T