3v4l.org

run code in 300+ PHP versions simultaneously
<?php $chars = [ 'a' => 'c', 'b' => 'd', 'c' => 'a', 'd' => 'e', 'e' => 'b', ]; $original = 'acdcxx'; // Encrypt $encrypted = ''; for ($i = 0; $i < strlen($original); $i++) { // If we find the character in our mapping array, use the mapped character. // If not, let's use the original character. $encrypted .= array_key_exists($original[$i], $chars) ? $chars[$original[$i]] : $original[$i]; } print_r($encrypted); // Decrypt $decrypted = ''; for ($i = 0; $i < strlen($encrypted); $i++) { // Find the correct key $key = array_search($encrypted[$i], $chars); // If the character existed, use the key. // If not, use the original character. $decrypted .= $key !== false ? $key : $encrypted[$i]; } echo PHP_EOL; print_r($decrypted);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 5
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 25
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 25
Branch analysis from position: 42
Branch analysis from position: 25
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 25
Branch analysis from position: 42
Branch analysis from position: 25
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 5
Branch analysis from position: 19
Branch analysis from position: 5
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 5
Branch analysis from position: 19
Branch analysis from position: 5
filename:       /in/vQAZj
function name:  (null)
number of ops:  47
compiled vars:  !0 = $chars, !1 = $original, !2 = $encrypted, !3 = $i, !4 = $decrypted, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, 'acdcxx'
   14     2        ASSIGN                                                   !2, ''
   16     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->16
   19     5    >   FETCH_DIM_R                                      ~10     !1, !3
          6        ARRAY_KEY_EXISTS                                         ~10, !0
          7      > JMPZ                                                     ~11, ->12
   20     8    >   FETCH_DIM_R                                      ~12     !1, !3
          9        FETCH_DIM_R                                      ~13     !0, ~12
         10        QM_ASSIGN                                        ~14     ~13
         11      > JMP                                                      ->14
   21    12    >   FETCH_DIM_R                                      ~15     !1, !3
         13        QM_ASSIGN                                        ~14     ~15
         14    >   ASSIGN_OP                                     8          !2, ~14
   16    15        PRE_INC                                                  !3
         16    >   STRLEN                                           ~18     !1
         17        IS_SMALLER                                               !3, ~18
         18      > JMPNZ                                                    ~19, ->5
   24    19    >   INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                                 
   27    22        ASSIGN                                                   !4, ''
   28    23        ASSIGN                                                   !3, 0
         24      > JMP                                                      ->39
   30    25    >   INIT_FCALL                                               'array_search'
         26        FETCH_DIM_R                                      ~23     !2, !3
         27        SEND_VAL                                                 ~23
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                         $24     
         30        ASSIGN                                                   !5, $24
   34    31        TYPE_CHECK                                  1018          !5
         32      > JMPZ                                                     ~26, ->35
   35    33    >   QM_ASSIGN                                        ~27     !5
         34      > JMP                                                      ->37
   36    35    >   FETCH_DIM_R                                      ~28     !2, !3
         36        QM_ASSIGN                                        ~27     ~28
         37    >   ASSIGN_OP                                     8          !4, ~27
   28    38        PRE_INC                                                  !3
         39    >   STRLEN                                           ~31     !2
         40        IS_SMALLER                                               !3, ~31
         41      > JMPNZ                                                    ~32, ->25
   39    42    >   ECHO                                                     '%0A'
   40    43        INIT_FCALL                                               'print_r'
         44        SEND_VAR                                                 !4
         45        DO_ICALL                                                 
         46      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.51 ms | 1006 KiB | 15 Q