3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjContainer { } class Array2Obj { public function isArrayAssociative(array $array) { return (bool) count(array_filter(array_keys($array), 'is_string')); } public function __CONSTRUCT(array $array) { if(isArrayAssociative($array)) { $obj = new ObjContainer; foreach($array as $key => $val) { if(is_array($val)) { $obj->{$key} = new Array2Obj($val); } else { $obj->{$key} = $val; } } return $obj; } else { $array = array(); foreach($array as $val) { if(is_array($val)) { $array[] = new Array2Obj($val); } else { $array[] = $val; } } return $array; } } } $array = ["database"=>["host"=>"localhost","dbname"=>"mydb","user"=>"root","password"=>""]]; $xml = new Array2Obj($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FPHKM
function name:  (null)
number of ops:  6
compiled vars:  !0 = $array, !1 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   ASSIGN                                                   !0, <array>
   35     1        NEW                                              $3      'Array2Obj'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
          5      > RETURN                                                   1

Class ObjContainer: [no user functions]
Class Array2Obj:
Function isarrayassociative:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FPHKM
function name:  isArrayAssociative
number of ops:  12
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'array_filter'
          2        INIT_FCALL                                               'array_keys'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        SEND_VAL                                                 'is_string'
          7        DO_ICALL                                         $2      
          8        COUNT                                            ~3      $2
          9        BOOL                                             ~4      ~3
         10      > RETURN                                                   ~4
    6    11*     > RETURN                                                   null

End of function isarrayassociative

Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 25
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 39
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 39
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 36
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/FPHKM
function name:  __CONSTRUCT
number of ops:  42
compiled vars:  !0 = $array, !1 = $obj, !2 = $val, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL_BY_NAME                                       'isArrayAssociative'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $4      
          4      > JMPZ                                                     $4, ->25
    9     5    >   NEW                                              $5      'ObjContainer'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   10     8      > FE_RESET_R                                       $8      !0, ->22
          9    > > FE_FETCH_R                                       ~9      $8, !2, ->22
         10    >   ASSIGN                                                   !3, ~9
   11    11        TYPE_CHECK                                  128          !2
         12      > JMPZ                                                     ~11, ->19
   12    13    >   NEW                                              $13     'Array2Obj'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0          
         16        ASSIGN_OBJ                                               !1, !3
         17        OP_DATA                                                  $13
         18      > JMP                                                      ->21
   15    19    >   ASSIGN_OBJ                                               !1, !3
         20        OP_DATA                                                  !2
   10    21    > > JMP                                                      ->9
         22    >   FE_FREE                                                  $8
   18    23      > RETURN                                                   !1
         24*       JMP                                                      ->41
   21    25    >   ASSIGN                                                   !0, <array>
   22    26      > FE_RESET_R                                       $17     !0, ->39
         27    > > FE_FETCH_R                                               $17, !2, ->39
   23    28    >   TYPE_CHECK                                  128          !2
         29      > JMPZ                                                     ~18, ->36
   24    30    >   NEW                                              $20     'Array2Obj'
         31        SEND_VAR_EX                                              !2
         32        DO_FCALL                                      0          
         33        ASSIGN_DIM                                               !0
         34        OP_DATA                                                  $20
         35      > JMP                                                      ->38
   27    36    >   ASSIGN_DIM                                               !0
         37        OP_DATA                                                  !2
   22    38    > > JMP                                                      ->27
         39    >   FE_FREE                                                  $17
   30    40      > RETURN                                                   !0
   32    41*     > RETURN                                                   null

End of function __construct

End of class Array2Obj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.92 ms | 1400 KiB | 17 Q