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), 'Seen' => array(array('UserID' => 2, 'Timestamp' => 5046), array('UserID' => 3, 'Timestamp' => 789456)), 'Active' => 1 ); $J = json_encode(array_utf8_encode($User)); die(($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(htmlentities($Val), 'UTF-8'); } } return $Array; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/3QoKs
function name:  (null)
number of ops:  10
compiled vars:  !0 = $User, !1 = $J
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'json_encode'
          2        INIT_FCALL_BY_NAME                                       'array_utf8_encode'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        SEND_VAR                                                 $3
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !1, $4
   11     8      > EXIT                                                     !1
   31     9*     > RETURN                                                   1

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

End of function array_utf8_encode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.52 ms | 1400 KiB | 19 Q