3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * 文字列の全パターン出力スクリプト * * @package Output * @version 1.0.0 * @since File available since Release 1.0.0 */ error_reporting(E_ALL); /** * ユーザIDをキーにキャッシュから本の配列を取得する。 * 取得出来ない場合はfalseを返す。 * * @param int $lock ロック桁(12345の内3までが固定の場合、3をロック桁) * @param arra $arr 出力対象文字列の配列化した値 * @param arra $srt $arrの出力順序 * @return array|bool */ function output($lock, $arr, $srt) { global $length; // ロック桁以降の全パターン出力 for($k=$lock; $k < $length; $k++) { // 下桁の2パターンになるまでlock桁を進める if($lock < $length - 3) { output($lock+1, $arr, $srt); } else { // 表示(lockまでと下二桁)x2 for($j=0; $j <= 1; $j++) { for($i=0; $i <= $lock; $i++) { echo $arr[$srt[$i]]; } echo $arr[$srt[$lock + $j + 1]]; echo $arr[$srt[$lock + 2 - $j]]; echo "\n"; } } // ロック桁の値の入れ替え(ロック桁以降でロック桁の次に大きい値) $w = $srt[$lock]; for($i=1;$i <= $length-$lock; $i++) { if (($next_addr = array_search($srt[$lock] + $i, array_slice($srt, $lock))) !== false) { $next_addr += $lock; break; } } $srt[$lock] = $srt[$next_addr]; $srt[$next_addr] = $w; } echo "\n"; } // main $str = 'cba'; // 対象文字列 $length = strlen($str); $arr = str_split($str); $srt = array_keys($arr); output(0, $arr, $srt);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YIAY3
function name:  (null)
number of ops:  20
compiled vars:  !0 = $str, !1 = $length, !2 = $arr, !3 = $srt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
   57     3        ASSIGN                                                   !0, 'cba'
   59     4        STRLEN                                           ~6      !0
          5        ASSIGN                                                   !1, ~6
   60     6        INIT_FCALL                                               'str_split'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !2, $8
   61    10        INIT_FCALL                                               'array_keys'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $10     
         13        ASSIGN                                                   !3, $10
   63    14        INIT_FCALL                                               'output'
         15        SEND_VAL                                                 0
         16        SEND_VAR                                                 !2
         17        SEND_VAR                                                 !3
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Function output:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 6
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 44
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 6
Branch analysis from position: 71
Branch analysis from position: 6
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 59
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 44
Branch analysis from position: 63
Branch analysis from position: 44
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 18
Branch analysis from position: 40
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 20
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 18
Branch analysis from position: 40
Branch analysis from position: 18
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 20
Branch analysis from position: 26
Branch analysis from position: 20
filename:       /in/YIAY3
function name:  output
number of ops:  73
compiled vars:  !0 = $lock, !1 = $arr, !2 = $srt, !3 = $length, !4 = $k, !5 = $j, !6 = $i, !7 = $w, !8 = $next_addr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   22     3        BIND_GLOBAL                                              !3, 'length'
   25     4        ASSIGN                                                   !4, !0
          5      > JMP                                                      ->69
   28     6    >   SUB                                              ~10     !3, 3
          7        IS_SMALLER                                               !0, ~10
          8      > JMPZ                                                     ~11, ->16
   29     9    >   INIT_FCALL_BY_NAME                                       'output'
         10        ADD                                              ~12     !0, 1
         11        SEND_VAL_EX                                              ~12
         12        SEND_VAR_EX                                              !1
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15      > JMP                                                      ->40
   32    16    >   ASSIGN                                                   !5, 0
         17      > JMP                                                      ->38
   33    18    >   ASSIGN                                                   !6, 0
         19      > JMP                                                      ->24
   34    20    >   FETCH_DIM_R                                      ~16     !2, !6
         21        FETCH_DIM_R                                      ~17     !1, ~16
         22        ECHO                                                     ~17
   33    23        PRE_INC                                                  !6
         24    >   IS_SMALLER_OR_EQUAL                                      !6, !0
         25      > JMPNZ                                                    ~19, ->20
   36    26    >   ADD                                              ~20     !0, !5
         27        ADD                                              ~21     ~20, 1
         28        FETCH_DIM_R                                      ~22     !2, ~21
         29        FETCH_DIM_R                                      ~23     !1, ~22
         30        ECHO                                                     ~23
   37    31        ADD                                              ~24     !0, 2
         32        SUB                                              ~25     ~24, !5
         33        FETCH_DIM_R                                      ~26     !2, ~25
         34        FETCH_DIM_R                                      ~27     !1, ~26
         35        ECHO                                                     ~27
   38    36        ECHO                                                     '%0A'
   32    37        PRE_INC                                                  !5
         38    >   IS_SMALLER_OR_EQUAL                                      !5, 1
         39      > JMPNZ                                                    ~29, ->18
   43    40    >   FETCH_DIM_R                                      ~30     !2, !0
         41        ASSIGN                                                   !7, ~30
   44    42        ASSIGN                                                   !6, 1
         43      > JMP                                                      ->60
   45    44    >   INIT_FCALL                                               'array_search'
         45        FETCH_DIM_R                                      ~33     !2, !0
         46        ADD                                              ~34     ~33, !6
         47        SEND_VAL                                                 ~34
         48        INIT_FCALL                                               'array_slice'
         49        SEND_VAR                                                 !2
         50        SEND_VAR                                                 !0
         51        DO_ICALL                                         $35     
         52        SEND_VAR                                                 $35
         53        DO_ICALL                                         $36     
         54        ASSIGN                                           ~37     !8, $36
         55        TYPE_CHECK                                  1018          ~37
         56      > JMPZ                                                     ~38, ->59
   46    57    >   ASSIGN_OP                                     1          !8, !0
   47    58      > JMP                                                      ->63
   44    59    >   PRE_INC                                                  !6
         60    >   SUB                                              ~41     !3, !0
         61        IS_SMALLER_OR_EQUAL                                      !6, ~41
         62      > JMPNZ                                                    ~42, ->44
   50    63    >   FETCH_DIM_R                                      ~44     !2, !8
         64        ASSIGN_DIM                                               !2, !0
         65        OP_DATA                                                  ~44
   51    66        ASSIGN_DIM                                               !2, !8
         67        OP_DATA                                                  !7
   25    68        PRE_INC                                                  !4
         69    >   IS_SMALLER                                               !4, !3
         70      > JMPNZ                                                    ~47, ->6
   53    71    >   ECHO                                                     '%0A'
   54    72      > RETURN                                                   null

End of function output

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.67 ms | 1407 KiB | 24 Q