note 118569 deleted from function.json-encode by cmb

From: Date: Sun, 04 Nov 2018 10:04:39 +0000
Subject: note 118569 deleted from function.json-encode by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-209607@lists.php.net to get a copy of this message
Note Submitter: rdeeceria ---- reading json pretty of my code. i have simple code for easy read array, object, path, etc json pretty print with str_replace ( \r \n \t ) and preg_replace ( \ ). function jsonDump ($a,$die = true) { $json = str_replace(array("\\r","\\n","\\t"), "",json_encode($a,JSON_PRETTY_PRINT)); $json = preg_replace('#(?<!\\\\)(\\$|\\\\)#', "", $json); echo'<pre>'; print_r($json); echo'</pre><hr>'; if($die) die(); } //input $infoPath = array ( 'method' => $_SERVER['REQUEST_METHOD'], 'status' => $status, 'dirbatch' => $dirbatch, 'pathData' => $path_data //array ); //output { "method": "GET", "status": "ins_tarif", "dirbatch": "C:\xampp\htdocs\simrs\services", "pathData": [ "E:\Brankas\Project\RSIA\SIMRS\dump\DOKTER.csv", "E:\Brankas\Project\RSIA\SIMRS\dump\GOLPAS.csv", "E:\Brankas\Project\RSIA\SIMRS\dump\PANGKAT.csv", "E:\Brankas\Project\RSIA\SIMRS\dump\PEMAKAI.csv" ] } Hope it works well for you :)

« previous php.notes (#209607) next »