3v4l.org

run code in 300+ PHP versions simultaneously
<?php $scan = "00:12:a9:54:f6:a7,Privacy,-52.00,3Com,6,30:91:8f:24:07:d0,RSN: Privacy,-85.00,CenturyLink3873,1,00:0c:e5:46:2d:74,ShortSlotTime,-92.00,WLAN,1,c0:3f:0e:57:87:e8,RSN: Privacy,-94.00,Megan-PC-Wireless,6,00:12:a9:54:f6:a7,ShortPreamble,-45.00,WLAN,7"; $escan = (explode(",",$scan)); $cscan = (array_chunk($escan, 5)); class Util { static function arrayToObject($array, $class = 'stdClass', $strict = false) { if (!is_array($array)) { return $array; } //create an instance of an class without calling class's constructor $object = unserialize( sprintf( 'O:%d:"%s":0:{}', strlen($class), $class ) ); if (is_array($array) && count($array) > 0) { foreach ($array as $name => $value) { $name = strtolower(trim($name)); var_dump($name); if (!empty($name)) { if(method_exists($object, 'set'.$name)){ $object->{'set'.$name}(Util::arrayToObject($value)); }else{ if(($strict)){ if(property_exists($class, $name)){ $object->$name = Util::arrayToObject($value); } }else{ $object->$name = Util::arrayToObject($value); } } } } return $object; } else { return FALSE; } } } $device = new Util($cscan); var_dump($device); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gh7uf
function name:  (null)
number of ops:  19
compiled vars:  !0 = $scan, !1 = $escan, !2 = $cscan, !3 = $device
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '00%3A12%3Aa9%3A54%3Af6%3Aa7%2CPrivacy%2C-52.00%2C3Com%2C6%2C30%3A91%3A8f%3A24%3A07%3Ad0%2CRSN%3A+Privacy%2C-85.00%2CCenturyLink3873%2C1%2C00%3A0c%3Ae5%3A46%3A2d%3A74%2CShortSlotTime%2C-92.00%2CWLAN%2C1%2Cc0%3A3f%3A0e%3A57%3A87%3Ae8%2CRSN%3A+Privacy%2C-94.00%2CMegan-PC-Wireless%2C6%2C00%3A12%3Aa9%3A54%3Af6%3Aa7%2CShortPreamble%2C-45.00%2CWLAN%2C7'
    3     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2C'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    5     6        INIT_FCALL                                               'array_chunk'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 5
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !2, $7
   54    11        NEW                                              $9      'Util'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $9
   56    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                                 
   58    18      > RETURN                                                   1

Class Util:
Function arraytoobject:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 74
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 71
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 71
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 70
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 53
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 65
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 64
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 64
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 70
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/gh7uf
function name:  arrayToObject
number of ops:  76
compiled vars:  !0 = $array, !1 = $class, !2 = $strict, !3 = $object, !4 = $value, !5 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'stdClass'
          2        RECV_INIT                                        !2      <false>
   11     3        TYPE_CHECK                                  128  ~6      !0
          4        BOOL_NOT                                         ~7      ~6
          5      > JMPZ                                                     ~7, ->7
   12     6    > > RETURN                                                   !0
   16     7    >   INIT_FCALL                                               'unserialize'
   17     8        INIT_FCALL                                               'sprintf'
   18     9        SEND_VAL                                                 'O%3A%25d%3A%22%25s%22%3A0%3A%7B%7D'
         10        STRLEN                                           ~8      !1
         11        SEND_VAL                                                 ~8
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $9      
         14        SEND_VAR                                                 $9
         15        DO_ICALL                                         $10     
   16    16        ASSIGN                                                   !3, $10
   22    17        TYPE_CHECK                                  128  ~12     !0
         18      > JMPZ_EX                                          ~12     ~12, ->22
         19    >   COUNT                                            ~13     !0
         20        IS_SMALLER                                       ~14     0, ~13
         21        BOOL                                             ~12     ~14
         22    > > JMPZ                                                     ~12, ->74
   23    23    > > FE_RESET_R                                       $15     !0, ->71
         24    > > FE_FETCH_R                                       ~16     $15, !4, ->71
         25    >   ASSIGN                                                   !5, ~16
   24    26        INIT_FCALL                                               'strtolower'
         27        INIT_FCALL                                               'trim'
         28        SEND_VAR                                                 !5
         29        DO_ICALL                                         $18     
         30        SEND_VAR                                                 $18
         31        DO_ICALL                                         $19     
         32        ASSIGN                                                   !5, $19
   25    33        INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !5
         35        DO_ICALL                                                 
   26    36        ISSET_ISEMPTY_CV                                 ~22     !5
         37        BOOL_NOT                                         ~23     ~22
         38      > JMPZ                                                     ~23, ->70
   28    39    >   INIT_FCALL                                               'method_exists'
         40        SEND_VAR                                                 !3
         41        CONCAT                                           ~24     'set', !5
         42        SEND_VAL                                                 ~24
         43        DO_ICALL                                         $25     
         44      > JMPZ                                                     $25, ->53
   29    45    >   CONCAT                                           ~26     'set', !5
         46        INIT_METHOD_CALL                                         !3, ~26
         47        INIT_STATIC_METHOD_CALL                                  'Util', 'arrayToObject'
         48        SEND_VAR                                                 !4
         49        DO_FCALL                                      0  $27     
         50        SEND_VAR_NO_REF_EX                                       $27
         51        DO_FCALL                                      0          
         52      > JMP                                                      ->70
   31    53    > > JMPZ                                                     !2, ->65
   33    54    >   INIT_FCALL                                               'property_exists'
         55        SEND_VAR                                                 !1
         56        SEND_VAR                                                 !5
         57        DO_ICALL                                         $29     
         58      > JMPZ                                                     $29, ->64
   35    59    >   INIT_STATIC_METHOD_CALL                                  'Util', 'arrayToObject'
         60        SEND_VAR                                                 !4
         61        DO_FCALL                                      0  $31     
         62        ASSIGN_OBJ                                               !3, !5
         63        OP_DATA                                                  $31
         64    > > JMP                                                      ->70
   40    65    >   INIT_STATIC_METHOD_CALL                                  'Util', 'arrayToObject'
         66        SEND_VAR                                                 !4
         67        DO_FCALL                                      0  $33     
         68        ASSIGN_OBJ                                               !3, !5
         69        OP_DATA                                                  $33
   23    70    > > JMP                                                      ->24
         71    >   FE_FREE                                                  $15
   47    72      > RETURN                                                   !3
         73*       JMP                                                      ->75
   49    74    > > RETURN                                                   <false>
   51    75*     > RETURN                                                   null

End of function arraytoobject

End of class Util.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
132.21 ms | 1409 KiB | 31 Q