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(isset($translations[$key])){ if(isset($translations[$lang][$key])){ return $translations[$key][$lang]; } elseif (isset($translations[$key]["de"])) { return $translations[$key]["de"]; } } return "missing key ".$key."_".$lang; } echo stringByLanguage("testkey2","fr"); var_dump($translations);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mZ2mV
function name:  (null)
number of ops:  10
compiled vars:  !0 = $translations
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'stringbylanguage'
          2        SEND_VAL                                                 'testkey2'
          3        SEND_VAL                                                 'fr'
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
   22     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function stringbylanguage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/mZ2mV
function name:  stringByLanguage
number of ops:  22
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        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !0
          3      > JMPZ                                                     ~3, ->17
   11     4    >   FETCH_DIM_IS                                     ~4      !2, !1
          5        ISSET_ISEMPTY_DIM_OBJ                         0          ~4, !0
          6      > JMPZ                                                     ~5, ->11
   12     7    >   FETCH_DIM_R                                      ~6      !2, !0
          8        FETCH_DIM_R                                      ~7      ~6, !1
          9      > RETURN                                                   ~7
         10*       JMP                                                      ->17
   13    11    >   FETCH_DIM_IS                                     ~8      !2, !0
         12        ISSET_ISEMPTY_DIM_OBJ                         0          ~8, 'de'
         13      > JMPZ                                                     ~9, ->17
   14    14    >   FETCH_DIM_R                                      ~10     !2, !0
         15        FETCH_DIM_R                                      ~11     ~10, 'de'
         16      > RETURN                                                   ~11
   17    17    >   CONCAT                                           ~12     'missing+key+', !0
         18        CONCAT                                           ~13     ~12, '_'
         19        CONCAT                                           ~14     ~13, !1
         20      > RETURN                                                   ~14
   18    21*     > RETURN                                                   null

End of function stringbylanguage

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.24 ms | 1399 KiB | 16 Q