3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json_data = array ('id'=>1,'name'=>"ля-ло-ля",'country'=>'Russia'); function json_encode_cyr($str) { $arr_replace_utf = array('\u0410', '\u0430','\u0411','\u0431','\u0412','\u0432', '\u0413','\u0433','\u0414','\u0434','\u0415','\u0435','\u0401','\u0451','\u0416', '\u0436','\u0417','\u0437','\u0418','\u0438','\u0419','\u0439','\u041a','\u043a', '\u041b','\u043b','\u041c','\u043c','\u041d','\u043d','\u041e','\u043e','\u041f', '\u043f','\u0420','\u0440','\u0421','\u0441','\u0422','\u0442','\u0423','\u0443', '\u0424','\u0444','\u0425','\u0445','\u0426','\u0446','\u0427','\u0447','\u0428', '\u0448','\u0429','\u0449','\u042a','\u044a','\u042b','\u044b','\u042c','\u044c', '\u042d','\u044d','\u042e','\u044e','\u042f','\u044f'); $arr_replace_cyr = array('А', 'а', 'Б', 'б', 'В', 'в', 'Г', 'г', 'Д', 'д', 'Е', 'е', 'Ё', 'ё', 'Ж','ж','З','з','И','и','Й','й','К','к','Л','л','М','м','Н','н','О','о', 'П','п','Р','р','С','с','Т','т','У','у','Ф','ф','Х','х','Ц','ц','Ч','ч','Ш','ш', 'Щ','щ','Ъ','ъ','Ы','ы','Ь','ь','Э','э','Ю','ю','Я','я'); $str1 = json_encode($str); $str2 = str_replace($arr_replace_utf,$arr_replace_cyr,$str1); return $str2; } echo json_encode($json_data);?> <br /> <?php echo json_encode_cyr(json_encode($json_data)); ?><br /> <?php echo json_encode($json_data, JSON_UNESCAPED_UNICODE); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vvntZ
function name:  (null)
number of ops:  20
compiled vars:  !0 = $json_data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   39     1        INIT_FCALL                                               'json_encode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ECHO                                                     $2
   40     5        ECHO                                                     '%3Cbr+%2F%3E%0A'
   43     6        INIT_FCALL                                               'json_encode_cyr'
          7        INIT_FCALL                                               'json_encode'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
         11        DO_FCALL                                      0  $4      
         12        ECHO                                                     $4
   44    13        ECHO                                                     '%3Cbr+%2F%3E%0A'
   45    14        INIT_FCALL                                               'json_encode'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 256
         17        DO_ICALL                                         $5      
         18        ECHO                                                     $5
         19      > RETURN                                                   1

Function json_encode_cyr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vvntZ
function name:  json_encode_cyr
number of ops:  15
compiled vars:  !0 = $str, !1 = $arr_replace_utf, !2 = $arr_replace_cyr, !3 = $str1, !4 = $str2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, <array>
   23     2        ASSIGN                                                   !2, <array>
   31     3        INIT_FCALL                                               'json_encode'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !3, $7
   33     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !4, $9
   35    13      > RETURN                                                   !4
   37    14*     > RETURN                                                   null

End of function json_encode_cyr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.23 ms | 1398 KiB | 18 Q