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 PHR"; $pattern = "/.*\s([A-Z])(\w+)/"; //$pattern = "/.*\s([A-Z])([A-Z]+)/"; pattern to match only all caps word preg_match($pattern, $str, $match); $letter = $match[1]; $word = $match[1] . $match[2]; $position = strrpos($str, $match[1].$match[2]); echo "Letter to find: " . $letter . "\nWord to find: " . $word . "\nPosition of letter: " . $position;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7dJjS
function name:  (null)
number of ops:  28
compiled vars:  !0 = $str, !1 = $pattern, !2 = $match, !3 = $letter, !4 = $word, !5 = $position
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+PHR'
    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                                                 
   11     7        FETCH_DIM_R                                      ~9      !2, 1
          8        ASSIGN                                                   !3, ~9
   12     9        FETCH_DIM_R                                      ~11     !2, 1
         10        FETCH_DIM_R                                      ~12     !2, 2
         11        CONCAT                                           ~13     ~11, ~12
         12        ASSIGN                                                   !4, ~13
   13    13        INIT_FCALL                                               'strrpos'
         14        SEND_VAR                                                 !0
         15        FETCH_DIM_R                                      ~15     !2, 1
         16        FETCH_DIM_R                                      ~16     !2, 2
         17        CONCAT                                           ~17     ~15, ~16
         18        SEND_VAL                                                 ~17
         19        DO_ICALL                                         $18     
         20        ASSIGN                                                   !5, $18
   15    21        CONCAT                                           ~20     'Letter+to+find%3A+', !3
         22        CONCAT                                           ~21     ~20, '%0AWord+to+find%3A+'
         23        CONCAT                                           ~22     ~21, !4
         24        CONCAT                                           ~23     ~22, '%0APosition+of+letter%3A+'
         25        CONCAT                                           ~24     ~23, !5
         26        ECHO                                                     ~24
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.38 ms | 1395 KiB | 17 Q