3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encode($str) { return preg_replace('/(.)\1*/', function($match) { return strlen($match[1]) . $match[2]; }, $str); } function decode($str) { return preg_replace('/(\d+)(\D)/', function($match) { return str_repeat($match[2], $match[1]); }, $str); } echo encode('WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW'), "\n"; echo decode('12W1B12W3B24W1B14W'), "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aV9eF
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'encode'
          1        SEND_VAL                                                 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4        ECHO                                                     '%0A'
   11     5        INIT_FCALL                                               'decode'
          6        SEND_VAL                                                 '12W1B12W3B24W1B14W'
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
          9        ECHO                                                     '%0A'
         10      > RETURN                                                   1

Function encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aV9eF
function name:  encode
number of ops:  9
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%28.%29%5C1%2A%2F'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaV9eF%3A3%240'
          4        SEND_VAL                                                 ~1
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    4     8*     > RETURN                                                   null

End of function encode

Function %00%7Bclosure%7D%2Fin%2FaV9eF%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aV9eF
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 1
          2        STRLEN                                           ~2      ~1
          3        FETCH_DIM_R                                      ~3      !0, 2
          4        CONCAT                                           ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaV9eF%3A3%240

Function decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aV9eF
function name:  decode
number of ops:  9
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%28%5Cd%2B%29%28%5CD%29%2F'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaV9eF%3A7%241'
          4        SEND_VAL                                                 ~1
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    8     8*     > RETURN                                                   null

End of function decode

Function %00%7Bclosure%7D%2Fin%2FaV9eF%3A7%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aV9eF
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'str_repeat'
          2        FETCH_DIM_R                                      ~1      !0, 2
          3        SEND_VAL                                                 ~1
          4        FETCH_DIM_R                                      ~2      !0, 1
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
          8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaV9eF%3A7%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.47 ms | 1403 KiB | 19 Q