3v4l.org

run code in 300+ PHP versions simultaneously
<?php print_r(hex2rgb("#AADDFF")); function hex2rgb($hex) { //if (substr($hex,0,1)=="#"): // $hex=substr($hex, 1); //endif; $hex = substr_replace($hex,""); if (strlen($hex)==3): $hex=$hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; elseif (strlen($hex)!=6): return false; else: $rgb=array(); $rgb[0] = hexdec(substr($hex,0,2)); // red $rgb[1] = hexdec(substr($hex,2,2)); // green $rgb[2] = hexdec(substr($hex,4,2)); // blue return $rgb; endif; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cho7E
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL_BY_NAME                                       'hex2rgb'
          2        SEND_VAL_EX                                              '%23AADDFF'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   25     6      > RETURN                                                   1

Function hex2rgb:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cho7E
function name:  hex2rgb
number of ops:  60
compiled vars:  !0 = $hex, !1 = $rgb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'substr_replace'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 ''
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
   12     6        STRLEN                                           ~4      !0
          7        IS_EQUAL                                                 ~4, 3
          8      > JMPZ                                                     ~5, ->22
   13     9    >   FETCH_DIM_R                                      ~6      !0, 0
         10        FETCH_DIM_R                                      ~7      !0, 0
         11        CONCAT                                           ~8      ~6, ~7
         12        FETCH_DIM_R                                      ~9      !0, 1
         13        CONCAT                                           ~10     ~8, ~9
         14        FETCH_DIM_R                                      ~11     !0, 1
         15        CONCAT                                           ~12     ~10, ~11
         16        FETCH_DIM_R                                      ~13     !0, 2
         17        CONCAT                                           ~14     ~12, ~13
         18        FETCH_DIM_R                                      ~15     !0, 2
         19        CONCAT                                           ~16     ~14, ~15
         20        ASSIGN                                                   !0, ~16
         21      > JMP                                                      ->59
   14    22    >   STRLEN                                           ~18     !0
         23        IS_NOT_EQUAL                                             ~18, 6
         24      > JMPZ                                                     ~19, ->27
   15    25    > > RETURN                                                   <false>
         26*       JMP                                                      ->59
   17    27    >   ASSIGN                                                   !1, <array>
   18    28        INIT_FCALL                                               'hexdec'
         29        INIT_FCALL                                               'substr'
         30        SEND_VAR                                                 !0
         31        SEND_VAL                                                 0
         32        SEND_VAL                                                 2
         33        DO_ICALL                                         $22     
         34        SEND_VAR                                                 $22
         35        DO_ICALL                                         $23     
         36        ASSIGN_DIM                                               !1, 0
         37        OP_DATA                                                  $23
   19    38        INIT_FCALL                                               'hexdec'
         39        INIT_FCALL                                               'substr'
         40        SEND_VAR                                                 !0
         41        SEND_VAL                                                 2
         42        SEND_VAL                                                 2
         43        DO_ICALL                                         $25     
         44        SEND_VAR                                                 $25
         45        DO_ICALL                                         $26     
         46        ASSIGN_DIM                                               !1, 1
         47        OP_DATA                                                  $26
   20    48        INIT_FCALL                                               'hexdec'
         49        INIT_FCALL                                               'substr'
         50        SEND_VAR                                                 !0
         51        SEND_VAL                                                 4
         52        SEND_VAL                                                 2
         53        DO_ICALL                                         $28     
         54        SEND_VAR                                                 $28
         55        DO_ICALL                                         $29     
         56        ASSIGN_DIM                                               !1, 2
         57        OP_DATA                                                  $29
   21    58      > RETURN                                                   !1
   23    59    > > RETURN                                                   null

End of function hex2rgb

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.59 ms | 1392 KiB | 21 Q