3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "this is a Test String to get the last index of word with an uppercase letter in PHP"; $pattern = "/.*\s([A-Z])(\w+)/"; //$pattern = "/.*\s([A-Z])[A-Z]+/"; preg_match($pattern, $str, $match); var_dump($match); $letter = $match[1]; $word = $match[1] . $match[2]; $position = strrpos($match[1].$match[2], $str); echo $letter . $word. $postion;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kivK2
function name:  (null)
number of ops:  28
compiled vars:  !0 = $str, !1 = $pattern, !2 = $match, !3 = $letter, !4 = $word, !5 = $position, !6 = $postion
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'this+is+a+Test+String+to+get+the+last+index+of+word+with+an+uppercase+letter+in+PHP'
    5     1        ASSIGN                                                   !1, '%2F.%2A%5Cs%28%5BA-Z%5D%29%28%5Cw%2B%29%2F'
    8     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
   10     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   12    10        FETCH_DIM_R                                      ~11     !2, 1
         11        ASSIGN                                                   !3, ~11
   13    12        FETCH_DIM_R                                      ~13     !2, 1
         13        FETCH_DIM_R                                      ~14     !2, 2
         14        CONCAT                                           ~15     ~13, ~14
         15        ASSIGN                                                   !4, ~15
   14    16        INIT_FCALL                                               'strrpos'
         17        FETCH_DIM_R                                      ~17     !2, 1
         18        FETCH_DIM_R                                      ~18     !2, 2
         19        CONCAT                                           ~19     ~17, ~18
         20        SEND_VAL                                                 ~19
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $20     
         23        ASSIGN                                                   !5, $20
   16    24        CONCAT                                           ~22     !3, !4
         25        CONCAT                                           ~23     ~22, !6
         26        ECHO                                                     ~23
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.01 ms | 1395 KiB | 19 Q