3v4l.org

run code in 300+ PHP versions simultaneously
<?php $variables = [ "own" => [ "type" => "bool", "value" => 0 ], "contr_name" => [ "type" => "bool", "value" => 0 ], "all_votes" => [ "type" => "int", "value" => 0 ], "contract_start" => [ "type" => "bool", "value" => 0 ], "contract_end" => [ "type" => "bool", "value" => 0 ], "T" => [ "type" => "clock", "value" => '' ], "a" => [ "type" => "int", "value" => 1 ], "candi_ID" => [ "type" => "int", "value" => 1 ], "voter_ID" => [ "type" => "int", "value" => 1 ], /* [] => [ "type" => '', "value" => '' ] */ ]; $variable = "own=1, contract_start=1"; function updateTheValue(&$variables,$variable) { // Split variable looking for into name and value $vars = explode(",", $variable); $match = false; foreach ($vars as $var){ $expbyequal = explode("=", $var); // If this key exists in main keys if ( in_array(trim($expbyequal[0]), array_keys($variables)) ) { // Compare value with stored value if ( $variables [trim($expbyequal[0])]['value'] == trim($expbyequal[1]) ) { $match = true; }else{ $variables[trim($expbyequal[0])]["value"] = trim($expbyequal[1]); $match = false; } } } return $match; } updateTheValue($variables,$variable); print_r($variables);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m8h8C
function name:  (null)
number of ops:  10
compiled vars:  !0 = $variables, !1 = $variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   64     1        ASSIGN                                                   !1, 'own%3D1%2C+contract_start%3D1'
   89     2        INIT_FCALL                                               'updatethevalue'
          3        SEND_REF                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0          
   91     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function updatethevalue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 54
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 54
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 53
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 53
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
filename:       /in/m8h8C
function name:  updateTheValue
number of ops:  57
compiled vars:  !0 = $variables, !1 = $variable, !2 = $vars, !3 = $match, !4 = $var, !5 = $expbyequal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   69     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2C'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
   70     7        ASSIGN                                                   !3, <false>
   72     8      > FE_RESET_R                                       $9      !2, ->54
          9    > > FE_FETCH_R                                               $9, !4, ->54
   73    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '%3D'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !5, $10
   76    15        INIT_FCALL                                               'in_array'
         16        INIT_FCALL                                               'trim'
         17        FETCH_DIM_R                                      ~12     !5, 0
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                         $13     
         20        SEND_VAR                                                 $13
         21        INIT_FCALL                                               'array_keys'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $14     
         24        SEND_VAR                                                 $14
         25        DO_ICALL                                         $15     
         26      > JMPZ                                                     $15, ->53
   79    27    >   INIT_FCALL                                               'trim'
         28        FETCH_DIM_R                                      ~16     !5, 0
         29        SEND_VAL                                                 ~16
         30        DO_ICALL                                         $17     
         31        FETCH_DIM_R                                      ~18     !0, $17
         32        FETCH_DIM_R                                      ~19     ~18, 'value'
         33        INIT_FCALL                                               'trim'
         34        FETCH_DIM_R                                      ~20     !5, 1
         35        SEND_VAL                                                 ~20
         36        DO_ICALL                                         $21     
         37        IS_EQUAL                                                 $21, ~19
         38      > JMPZ                                                     ~22, ->41
   80    39    >   ASSIGN                                                   !3, <true>
   79    40      > JMP                                                      ->53
   82    41    >   INIT_FCALL                                               'trim'
         42        FETCH_DIM_R                                      ~24     !5, 0
         43        SEND_VAL                                                 ~24
         44        DO_ICALL                                         $25     
         45        INIT_FCALL                                               'trim'
         46        FETCH_DIM_R                                      ~28     !5, 1
         47        SEND_VAL                                                 ~28
         48        DO_ICALL                                         $29     
         49        FETCH_DIM_W                                      $26     !0, $25
         50        ASSIGN_DIM                                               $26, 'value'
         51        OP_DATA                                                  $29
   83    52        ASSIGN                                                   !3, <false>
   72    53    > > JMP                                                      ->9
         54    >   FE_FREE                                                  $9
   87    55      > RETURN                                                   !3
   88    56*     > RETURN                                                   null

End of function updatethevalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.77 ms | 1009 KiB | 19 Q