3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* what I want to achieve*/ $rules= [ 'title' => 'required|min:2|max:5', ]; /////////////////////////////////////////// $types = ['min' => 2, 'max' => 5, 'required'=> 1]; function ruleTypes(array $types){ $arr = []; foreach($types as $key => $value) { $arr[] = $key . ':' . $value; } return implode('|', $arr); } $arrayOfRules = [ 'title' => ruleTypes($types), ]; var_dump($arrayOfRules);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FJ5ll
function name:  (null)
number of ops:  11
compiled vars:  !0 = $rules, !1 = $types, !2 = $arrayOfRules
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   19     2        INIT_FCALL                                               'ruletypes'
          3        SEND_VAR                                                 !1
          4        DO_FCALL                                      0  $5      
          5        INIT_ARRAY                                       ~6      $5, 'title'
   18     6        ASSIGN                                                   !2, ~6
   23     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function ruletypes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/FJ5ll
function name:  ruleTypes
number of ops:  17
compiled vars:  !0 = $types, !1 = $arr, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $5      !0, ->10
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->10
          4    >   ASSIGN                                                   !3, ~6
   13     5        CONCAT                                           ~9      !3, '%3A'
          6        CONCAT                                           ~10     ~9, !2
          7        ASSIGN_DIM                                               !1
          8        OP_DATA                                                  ~10
   12     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $5
   15    11        INIT_FCALL                                               'implode'
         12        SEND_VAL                                                 '%7C'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $11     
         15      > RETURN                                                   $11
   16    16*     > RETURN                                                   null

End of function ruletypes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.48 ms | 1399 KiB | 18 Q