- mb_convert_encoding: documentation ( source)
- preg_replace_callback: documentation ( source)
- pack: documentation ( source)
- json_encode: documentation ( source)
<?php
$User = array(
'Name' => "Hans-Peterµµ",
'Contacts' => array(1, 2, 3, 4, 5, 6, 7, 42),
'Active' => 1
); foreach ($J as &$val) {
$val = preg_replace_callback('/\\\\u([0-9a-f]{4})/i',
function($matches) {
return mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UTF-16');
}, $val);
$J = json_encode($User);}
echo $J;