Search
 
SCRIPT & CODE EXAMPLE
 

PHP

json_encode alternative


For PHP5.3 users who want to emulate JSON_UNESCAPED_UNICODE, there is simple way to do it:
<?php
function my_json_encode($arr)
{
        //convmap since 0x80 char codes so it takes all multibyte codes (above ASCII 127). So such characters are being "hidden" from normal json_encoding
        array_walk_recursive($arr, function (&$item, $key) { if (is_string($item)) $item = mb_encode_numericentity($item, array (0x80, 0xffff, 0, 0xffff), 'UTF-8'); });
        return mb_decode_numericentity(json_encode($arr), array (0x80, 0xffff, 0, 0xffff), 'UTF-8');

}
?>

Comment

PREVIOUS NEXT
Code Example
Php :: {{count laravel 
Php :: laravel e commerce full project 
Php :: laravel outer join 
Php :: laravel blade @auth 
Php :: mysql extension php enable 
Php :: Codeigniter 3 Get future date recocords - upcoming records from database 
Php :: dispatch job with queue name in laravel 
Php :: showing custom post type in wordpress website 
Php :: if exists in string count php 
Php :: autoloader php 
Php :: laravel on cascade set null 
Php :: get_adjacent_post wordpress 
Php :: laravel with and where 
Php :: php http method 
Php :: laravel where 2 column 
Php :: livewire call another component 
Php :: php dies while parsing json 
Php :: php header not working 
Php :: display money format php 
Php :: generate fake name php 
Php :: woocommerce order status change 
Php :: php json_encode indent 
Php :: PDO encode result recordset to utf8 
Php :: get data from csv file in php and print in table 
Php :: carbon if date is today 
Php :: laravel import data from csv 
Php :: array shift php 
Php :: Laravel - Send mail using mail class 
Php :: append in php 
Php :: drupal 7 db_query example 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =