3v4l.org

run code in 300+ PHP versions simultaneously
<?php $translations = ["testkey" => ["de" => "TESTKEYDEUTSCH", "en" => "TESTKEYENGLISH"], "testkey2" => ["de" => "TESTKEYDEUTSCH", "en" => "TESTKEYENGLISH"], ]; function stringByLanguage($key, $lang) { var_dump(array_key_exists($key, $translations)); if(isset($translations[$key])){ var_dump(isset($translations[$key][$lang])); if(isset($translations[$key][$lang])){ return $translations[$key][$lang]; } elseif (isset($translations[$key]["de"])) { return $translations[$key]["de"]; } } return "missing key ".$key."_".$lang; } echo stringByLanguage("testkey2","fr");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5BLFA
function name:  (null)
number of ops:  7
compiled vars:  !0 = $translations
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'stringbylanguage'
          2        SEND_VAL                                                 'testkey2'
          3        SEND_VAL                                                 'fr'
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6      > RETURN                                                   1

Function stringbylanguage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/5BLFA
function name:  stringByLanguage
number of ops:  31
compiled vars:  !0 = $key, !1 = $lang, !2 = $translations
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'var_dump'
          3        ARRAY_KEY_EXISTS                                 ~3      !0, !2
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                                 
   11     6        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !0
          7      > JMPZ                                                     ~5, ->26
   12     8    >   INIT_FCALL                                               'var_dump'
          9        FETCH_DIM_IS                                     ~6      !2, !0
         10        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      ~6, !1
         11        SEND_VAL                                                 ~7
         12        DO_ICALL                                                 
   13    13        FETCH_DIM_IS                                     ~9      !2, !0
         14        ISSET_ISEMPTY_DIM_OBJ                         0          ~9, !1
         15      > JMPZ                                                     ~10, ->20
   14    16    >   FETCH_DIM_R                                      ~11     !2, !0
         17        FETCH_DIM_R                                      ~12     ~11, !1
         18      > RETURN                                                   ~12
         19*       JMP                                                      ->26
   15    20    >   FETCH_DIM_IS                                     ~13     !2, !0
         21        ISSET_ISEMPTY_DIM_OBJ                         0          ~13, 'de'
         22      > JMPZ                                                     ~14, ->26
   16    23    >   FETCH_DIM_R                                      ~15     !2, !0
         24        FETCH_DIM_R                                      ~16     ~15, 'de'
         25      > RETURN                                                   ~16
   19    26    >   CONCAT                                           ~17     'missing+key+', !0
         27        CONCAT                                           ~18     ~17, '_'
         28        CONCAT                                           ~19     ~18, !1
         29      > RETURN                                                   ~19
   20    30*     > RETURN                                                   null

End of function stringbylanguage

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.86 ms | 948 KiB | 17 Q