3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lookup = ['neither', 'upper', 'lower']; $tests = ['A', 'z', '+', '0', 'ǻ', 'Ͱ', null]; foreach ($tests as $test) { if (preg_match('~(\p{Lu})|(\p{Ll})~u', $test, $out)) { end($out); // advance pointer to final element $index = key($out); } else { $index = 0; } echo "{$test}: {$lookup[$index]}\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 26
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/HEGaT
function name:  (null)
number of ops:  28
compiled vars:  !0 = $lookup, !1 = $tests, !2 = $test, !3 = $out, !4 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $7      !1, ->26
          3    > > FE_FETCH_R                                               $7, !2, ->26
    6     4    >   INIT_FCALL                                               'preg_match'
          5        SEND_VAL                                                 '%7E%28%5Cp%7BLu%7D%29%7C%28%5Cp%7BLl%7D%29%7Eu'
          6        SEND_VAR                                                 !2
          7        SEND_REF                                                 !3
          8        DO_ICALL                                         $8      
          9      > JMPZ                                                     $8, ->18
    7    10    >   INIT_FCALL                                               'end'
         11        SEND_REF                                                 !3
         12        DO_ICALL                                                 
    8    13        INIT_FCALL                                               'key'
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !4, $10
         17      > JMP                                                      ->19
   10    18    >   ASSIGN                                                   !4, 0
   12    19    >   ROPE_INIT                                     4  ~15     !2
         20        ROPE_ADD                                      1  ~15     ~15, '%3A+'
         21        FETCH_DIM_R                                      ~13     !0, !4
         22        ROPE_ADD                                      2  ~15     ~15, ~13
         23        ROPE_END                                      3  ~14     ~15, '%0A'
         24        ECHO                                                     ~14
    5    25      > JMP                                                      ->3
         26    >   FE_FREE                                                  $7
   13    27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.45 ms | 1401 KiB | 19 Q