3v4l.org

run code in 300+ PHP versions simultaneously
<?php $User = array( 'Name' => "Hans-Peterµµ", 'Contacts' => array(1, 2, 3, 4, 5, 6, 7, 42), 'Active' => 1 ); foreach ($User 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(array_utf8_encode($User)); echo $J; function array_utf8_encode($Array) { foreach($Array as &$Val) { if(is_array($Val)) { $Val = array_utf8_encode($Val); } elseif(is_string($Val)) { $Val = mb_convert_encoding($Val, 'UTF-16'); } } return $Array; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/qFN0I
function name:  (null)
number of ops:  21
compiled vars:  !0 = $User, !1 = $val, !2 = $J
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    6     1      > FE_RESET_RW                                      $4      !0, ->11
          2    > > FE_FETCH_RW                                              $4, !1, ->11
    7     3    >   INIT_FCALL                                               'preg_replace_callback'
          4        SEND_VAL                                                 '%2F%5C%5Cu%28%5B0-9a-f%5D%7B4%7D%29%2Fi'
    8     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FqFN0I%3A8%240'
   10     6        SEND_VAL                                                 ~5
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $6      
    7     9        ASSIGN                                                   !1, $6
    6    10      > JMP                                                      ->2
         11    >   FE_FREE                                                  $4
   11    12        INIT_FCALL                                               'json_encode'
         13        INIT_FCALL_BY_NAME                                       'array_utf8_encode'
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !2, $9
   12    19        ECHO                                                     !2
   36    20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FqFN0I%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qFN0I
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'mb_convert_encoding'
          2        INIT_FCALL                                               'pack'
          3        SEND_VAL                                                 'H%2A'
          4        FETCH_DIM_R                                      ~1      !0, 1
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        SEND_VAL                                                 'UTF-8'
          9        SEND_VAL                                                 'UTF-16'
         10        DO_ICALL                                         $3      
         11      > RETURN                                                   $3
   10    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FqFN0I%3A8%240

Function array_utf8_encode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 18
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 17
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/qFN0I
function name:  array_utf8_encode
number of ops:  21
compiled vars:  !0 = $Array, !1 = $Val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1      > FE_RESET_RW                                      $2      !0, ->18
          2    > > FE_FETCH_RW                                              $2, !1, ->18
   20     3    >   TYPE_CHECK                                  128          !1
          4      > JMPZ                                                     ~3, ->10
   22     5    >   INIT_FCALL_BY_NAME                                       'array_utf8_encode'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $4      
          8        ASSIGN                                                   !1, $4
          9      > JMP                                                      ->17
   26    10    >   TYPE_CHECK                                   64          !1
         11      > JMPZ                                                     ~6, ->17
   28    12    >   INIT_FCALL                                               'mb_convert_encoding'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 'UTF-16'
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !1, $7
   18    17    > > JMP                                                      ->2
         18    >   FE_FREE                                                  $2
   34    19      > RETURN                                                   !0
   36    20*     > RETURN                                                   null

End of function array_utf8_encode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.1 ms | 1400 KiB | 21 Q