3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); $data = array ( 'tram B' => array ( 0 => array ( 'name' => 'Ile Verte' , 'distance' => 298, 'stationID' => 762, ), 1 => array ( 'name' => 'La Tronche Hôpital' , 'distance' => 425, 'stationID' => 771, ), ), 16 => array ( 0 => array ( 'name' => 'Bastille', 'distance' => 531, 'stationID' => 397 ), 1 => array ( 'name' => 'Xavier Jouvin', 'distance' => 589, 'stationID' => 438, ), ), ); $data['tram B'][1]['name'] = iconv('UTF8', 'ISO-8859-1', $data['tram B'][1]['name']); $fromEncoding = 'ISO-8859-1'; // This depends on the data array_walk_recursive($data, function (&$value, $key, $fromEncoding) { if (is_string($value)) { $value = iconv($fromEncoding, 'UTF-8', $value); } }, $fromEncoding); var_dump( mb_detect_order(), mb_detect_encoding($data['tram B'][1]['name']), mb_detect_encoding($data['tram B'][1]['name'], array('ISO-8859-1', 'UTF-8')), json_encode($data) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qUQEB
function name:  (null)
number of ops:  49
compiled vars:  !0 = $data, !1 = $fromEncoding
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
    4     3        ASSIGN                                                   !0, <array>
   37     4        INIT_FCALL_BY_NAME                                       'iconv'
          5        SEND_VAL_EX                                              'UTF8'
          6        SEND_VAL_EX                                              'ISO-8859-1'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $7      !0, 'tram+B'
          9        FETCH_DIM_FUNC_ARG                               $8      $7, 1
         10        FETCH_DIM_FUNC_ARG                               $9      $8, 'name'
         11        SEND_FUNC_ARG                                            $9
         12        DO_FCALL                                      0  $10     
         13        FETCH_DIM_W                                      $4      !0, 'tram+B'
         14        FETCH_DIM_W                                      $5      $4, 1
         15        ASSIGN_DIM                                               $5, 'name'
         16        OP_DATA                                                  $10
   39    17        ASSIGN                                                   !1, 'ISO-8859-1'
   41    18        INIT_FCALL                                               'array_walk_recursive'
         19        SEND_REF                                                 !0
         20        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FqUQEB%3A41%240'
   45    21        SEND_VAL                                                 ~12
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
   47    24        INIT_FCALL                                               'var_dump'
   48    25        INIT_FCALL                                               'mb_detect_order'
         26        DO_ICALL                                         $14     
         27        SEND_VAR                                                 $14
   49    28        INIT_FCALL                                               'mb_detect_encoding'
         29        FETCH_DIM_R                                      ~15     !0, 'tram+B'
         30        FETCH_DIM_R                                      ~16     ~15, 1
         31        FETCH_DIM_R                                      ~17     ~16, 'name'
         32        SEND_VAL                                                 ~17
         33        DO_ICALL                                         $18     
         34        SEND_VAR                                                 $18
   50    35        INIT_FCALL                                               'mb_detect_encoding'
         36        FETCH_DIM_R                                      ~19     !0, 'tram+B'
         37        FETCH_DIM_R                                      ~20     ~19, 1
         38        FETCH_DIM_R                                      ~21     ~20, 'name'
         39        SEND_VAL                                                 ~21
         40        SEND_VAL                                                 <array>
         41        DO_ICALL                                         $22     
         42        SEND_VAR                                                 $22
   51    43        INIT_FCALL                                               'json_encode'
         44        SEND_VAR                                                 !0
         45        DO_ICALL                                         $23     
         46        SEND_VAR                                                 $23
         47        DO_ICALL                                                 
   52    48      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FqUQEB%3A41%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/qUQEB
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $value, !1 = $key, !2 = $fromEncoding
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   42     3        TYPE_CHECK                                   64          !0
          4      > JMPZ                                                     ~3, ->11
   43     5    >   INIT_FCALL_BY_NAME                                       'iconv'
          6        SEND_VAR_EX                                              !2
          7        SEND_VAL_EX                                              'UTF-8'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $4      
         10        ASSIGN                                                   !0, $4
   45    11    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FqUQEB%3A41%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
218.83 ms | 1405 KiB | 28 Q