3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '^4Hello World ^5Foo^8Bar'; $colorMap = array( '000000', // 0 'ff0000', // 1 '00ff00', // 2 'ffff00', // 3 '0000ff', // 4 '00ffff', // 5 'ff00ff', // 6 'ffffff', // 7 'CC9933', // 8 '8D8D8D', // 9 ); $parts = preg_split('/\^(\d)/', $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); $result = ''; foreach($parts as $idx => $part) if((($idx % 2) === 0) && isset($colorMap[(int)$part])) $result .= sprintf('<span style="color:#%s">%s</span>', $colorMap[(int)$part], $parts[$idx + 1]); print $result;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 31
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 30
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 30
Branch analysis from position: 19
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/4bklX
function name:  (null)
number of ops:  34
compiled vars:  !0 = $str, !1 = $colorMap, !2 = $parts, !3 = $result, !4 = $part, !5 = $idx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '%5E4Hello+World+%5E5Foo%5E8Bar'
    5     1        ASSIGN                                                   !1, <array>
   19     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAL                                                 '%2F%5C%5E%28%5Cd%29%2F'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 -1
          6        SEND_VAL                                                 3
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !2, $8
   20     9        ASSIGN                                                   !3, ''
   22    10      > FE_RESET_R                                       $11     !2, ->31
         11    > > FE_FETCH_R                                       ~12     $11, !4, ->31
         12    >   ASSIGN                                                   !5, ~12
   23    13        MOD                                              ~14     !5, 2
         14        IS_IDENTICAL                                     ~15     ~14, 0
         15      > JMPZ_EX                                          ~15     ~15, ->19
         16    >   CAST                                          4  ~16     !4
         17        ISSET_ISEMPTY_DIM_OBJ                         0  ~17     !1, ~16
         18        BOOL                                             ~15     ~17
         19    > > JMPZ                                                     ~15, ->30
   24    20    >   INIT_FCALL                                               'sprintf'
         21        SEND_VAL                                                 '%3Cspan+style%3D%22color%3A%23%25s%22%3E%25s%3C%2Fspan%3E'
         22        CAST                                          4  ~18     !4
         23        FETCH_DIM_R                                      ~19     !1, ~18
         24        SEND_VAL                                                 ~19
         25        ADD                                              ~20     !5, 1
         26        FETCH_DIM_R                                      ~21     !2, ~20
         27        SEND_VAL                                                 ~21
         28        DO_ICALL                                         $22     
         29        ASSIGN_OP                                     8          !3, $22
   22    30    > > JMP                                                      ->11
         31    >   FE_FREE                                                  $11
   26    32        ECHO                                                     !3
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.57 ms | 1396 KiB | 17 Q