3v4l.org

run code in 500+ 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 = 7, Position 2 = 35
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DEMht
function name:  hex2rgb
number of ops:  59
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        FRAMELESS_ICALL_3                str_replace         ~5      '%23', ''
          2        OP_DATA                                                      !0
          3        ASSIGN                                                       !0, ~5
    6     4        STRLEN                                               ~7      !0
          5        IS_EQUAL                                                     ~7, 3
          6      > JMPZ                                                         ~8, ->35
    7     7    >   INIT_FCALL                                                   'hexdec'
          8        FRAMELESS_ICALL_3                substr              ~9      !0, 0
          9        OP_DATA                                                      1
         10        FRAMELESS_ICALL_3                substr              ~10     !0, 0
         11        OP_DATA                                                      1
         12        CONCAT                                               ~11     ~9, ~10
         13        SEND_VAL                                                     ~11
         14        DO_ICALL                                             $12     
         15        ASSIGN                                                       !1, $12
    8    16        INIT_FCALL                                                   'hexdec'
         17        FRAMELESS_ICALL_3                substr              ~14     !0, 1
         18        OP_DATA                                                      1
         19        FRAMELESS_ICALL_3                substr              ~15     !0, 1
         20        OP_DATA                                                      1
         21        CONCAT                                               ~16     ~14, ~15
         22        SEND_VAL                                                     ~16
         23        DO_ICALL                                             $17     
         24        ASSIGN                                                       !2, $17
    9    25        INIT_FCALL                                                   'hexdec'
         26        FRAMELESS_ICALL_3                substr              ~19     !0, 2
         27        OP_DATA                                                      1
         28        FRAMELESS_ICALL_3                substr              ~20     !0, 2
         29        OP_DATA                                                      1
         30        CONCAT                                               ~21     ~19, ~20
         31        SEND_VAL                                                     ~21
         32        DO_ICALL                                             $22     
         33        ASSIGN                                                       !3, $22
    6    34      > JMP                                                          ->53
   11    35    >   INIT_FCALL                                                   'hexdec'
         36        FRAMELESS_ICALL_3                substr              ~24     !0, 0
         37        OP_DATA                                                      2
         38        SEND_VAL                                                     ~24
         39        DO_ICALL                                             $25     
         40        ASSIGN                                                       !1, $25
   12    41        INIT_FCALL                                                   'hexdec'
         42        FRAMELESS_ICALL_3                substr              ~27     !0, 2
         43        OP_DATA                                                      2
         44        SEND_VAL                                                     ~27
         45        DO_ICALL                                             $28     
         46        ASSIGN                                                       !2, $28
   13    47        INIT_FCALL                                                   'hexdec'
         48        FRAMELESS_ICALL_3                substr              ~30     !0, 4
         49        OP_DATA                                                      2
         50        SEND_VAL                                                     ~30
         51        DO_ICALL                                             $31     
         52        ASSIGN                                                       !3, $31
   15    53    >   INIT_ARRAY                                           ~33     !1
         54        ADD_ARRAY_ELEMENT                                    ~33     !2
         55        ADD_ARRAY_ELEMENT                                    ~33     !3
         56        ASSIGN                                                       !4, ~33
   17    57      > RETURN                                                       !4
   18    58*     > RETURN                                                       null

End of function hex2rgb

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.47 ms | 3363 KiB | 16 Q