note 107369 deleted from function.json-encode by cmb
| From: | cmb@php.net | Date: | Mon, 21 Nov 2016 19:47:22 +0000 |
| Subject: | note 107369 deleted from function.json-encode by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207317@lists.php.net to get a copy of this message | ||
Note Submitter: pahreg at inbox dot ru
----
Simple replacement for JSON_UNESCAPED_UNICODE (PHP < 5.4 for example)
Can be buggy, but works for simple UTF-8 strings.
<?php
$json = preg_replace_callback('/\\\u(\w\w\w\w)/',
function($matches)
{
return '&#'.hexdec($matches[1]).';';
}
, json_encode($array));
?>