3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hex2rgb($hex) { $hex = str_replace("#", "", $hex); if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)); } else { $r = hexdec(substr($hex,0,2)); $g = hexdec(substr($hex,2,2)); $b = hexdec(substr($hex,4,2)); } $rgb = array($r, $g, $b); //return implode(",", $rgb); // returns the rgb values separated by commas return $rgb; // returns an array with the rgb values } $hex ="#ff1a1a"; print_r(hex2rgb($hex));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DEMht
function name:  (null)
number of ops:  8
compiled vars:  !0 = $hex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, '%23ff1a1a'
   21     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'hex2rgb'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function hex2rgb:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 56
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 83
Branch analysis from position: 83
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DEMht
function name:  hex2rgb
number of ops:  89
compiled vars:  !0 = $hex, !1 = $r, !2 = $g, !3 = $b, !4 = $rgb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%23'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !0, $5
    6     7        STRLEN                                           ~7      !0
          8        IS_EQUAL                                                 ~7, 3
          9      > JMPZ                                                     ~8, ->56
    7    10    >   INIT_FCALL                                               'hexdec'
         11        INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 0
         14        SEND_VAL                                                 1
         15        DO_ICALL                                         $9      
         16        INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 0
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $10     
         21        CONCAT                                           ~11     $9, $10
         22        SEND_VAL                                                 ~11
         23        DO_ICALL                                         $12     
         24        ASSIGN                                                   !1, $12
    8    25        INIT_FCALL                                               'hexdec'
         26        INIT_FCALL                                               'substr'
         27        SEND_VAR                                                 !0
         28        SEND_VAL                                                 1
         29        SEND_VAL                                                 1
         30        DO_ICALL                                         $14     
         31        INIT_FCALL                                               'substr'
         32        SEND_VAR                                                 !0
         33        SEND_VAL                                                 1
         34        SEND_VAL                                                 1
         35        DO_ICALL                                         $15     
         36        CONCAT                                           ~16     $14, $15
         37        SEND_VAL                                                 ~16
         38        DO_ICALL                                         $17     
         39        ASSIGN                                                   !2, $17
    9    40        INIT_FCALL                                               'hexdec'
         41        INIT_FCALL                                               'substr'
         42        SEND_VAR                                                 !0
         43        SEND_VAL                                                 2
         44        SEND_VAL                                                 1
         45        DO_ICALL                                         $19     
         46        INIT_FCALL                                               'substr'
         47        SEND_VAR                                                 !0
         48        SEND_VAL                                                 2
         49        SEND_VAL                                                 1
         50        DO_ICALL                                         $20     
         51        CONCAT                                           ~21     $19, $20
         52        SEND_VAL                                                 ~21
         53        DO_ICALL                                         $22     
         54        ASSIGN                                                   !3, $22
         55      > JMP                                                      ->83
   11    56    >   INIT_FCALL                                               'hexdec'
         57        INIT_FCALL                                               'substr'
         58        SEND_VAR                                                 !0
         59        SEND_VAL                                                 0
         60        SEND_VAL                                                 2
         61        DO_ICALL                                         $24     
         62        SEND_VAR                                                 $24
         63        DO_ICALL                                         $25     
         64        ASSIGN                                                   !1, $25
   12    65        INIT_FCALL                                               'hexdec'
         66        INIT_FCALL                                               'substr'
         67        SEND_VAR                                                 !0
         68        SEND_VAL                                                 2
         69        SEND_VAL                                                 2
         70        DO_ICALL                                         $27     
         71        SEND_VAR                                                 $27
         72        DO_ICALL                                         $28     
         73        ASSIGN                                                   !2, $28
   13    74        INIT_FCALL                                               'hexdec'
         75        INIT_FCALL                                               'substr'
         76        SEND_VAR                                                 !0
         77        SEND_VAL                                                 4
         78        SEND_VAL                                                 2
         79        DO_ICALL                                         $30     
         80        SEND_VAR                                                 $30
         81        DO_ICALL                                         $31     
         82        ASSIGN                                                   !3, $31
   15    83    >   INIT_ARRAY                                       ~33     !1
         84        ADD_ARRAY_ELEMENT                                ~33     !2
         85        ADD_ARRAY_ELEMENT                                ~33     !3
         86        ASSIGN                                                   !4, ~33
   17    87      > RETURN                                                   !4
   18    88*     > RETURN                                                   null

End of function hex2rgb

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.07 ms | 1407 KiB | 22 Q