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) { if(array_key_exists($key, $translations)){ var_dump(array_key_exists($key, $translations["key"])); 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/CB2hO
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>
   21     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 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/CB2hO
function name:  stringByLanguage
number of ops:  27
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        ARRAY_KEY_EXISTS                                         !0, !2
          3      > JMPZ                                                     ~3, ->22
   11     4    >   INIT_FCALL                                               'var_dump'
          5        FETCH_DIM_R                                      ~4      !2, 'key'
          6        ARRAY_KEY_EXISTS                                 ~5      !0, ~4
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                                 
   12     9        FETCH_DIM_IS                                     ~7      !2, !0
         10        ISSET_ISEMPTY_DIM_OBJ                         0          ~7, !1
         11      > JMPZ                                                     ~8, ->16
   13    12    >   FETCH_DIM_R                                      ~9      !2, !0
         13        FETCH_DIM_R                                      ~10     ~9, !1
         14      > RETURN                                                   ~10
         15*       JMP                                                      ->22
   14    16    >   FETCH_DIM_IS                                     ~11     !2, !0
         17        ISSET_ISEMPTY_DIM_OBJ                         0          ~11, 'de'
         18      > JMPZ                                                     ~12, ->22
   15    19    >   FETCH_DIM_R                                      ~13     !2, !0
         20        FETCH_DIM_R                                      ~14     ~13, 'de'
         21      > RETURN                                                   ~14
   18    22    >   CONCAT                                           ~15     'missing+key+', !0
         23        CONCAT                                           ~16     ~15, '_'
         24        CONCAT                                           ~17     ~16, !1
         25      > RETURN                                                   ~17
   19    26*     > RETURN                                                   null

End of function stringbylanguage

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.6 ms | 1402 KiB | 16 Q