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); $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/sJilv
function name:  (null)
number of ops:  29
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+PHP'
    5     1        ASSIGN                                                   !1, '%2F.%2A%5Cs%28%5BA-Z%5D%29%28%5Cw%2B%29%2F'
    6     2        ASSIGN                                                   !1, '%2F.%2A%5Cs%28%5BA-Z%5D%29%28%5BA-Z%5D%2B%29%2F'
    8     3        INIT_FCALL                                               'preg_match'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !0
          6        SEND_REF                                                 !2
          7        DO_ICALL                                                 
   11     8        FETCH_DIM_R                                      ~10     !2, 1
          9        ASSIGN                                                   !3, ~10
   12    10        FETCH_DIM_R                                      ~12     !2, 1
         11        FETCH_DIM_R                                      ~13     !2, 2
         12        CONCAT                                           ~14     ~12, ~13
         13        ASSIGN                                                   !4, ~14
   13    14        INIT_FCALL                                               'strrpos'
         15        SEND_VAR                                                 !0
         16        FETCH_DIM_R                                      ~16     !2, 1
         17        FETCH_DIM_R                                      ~17     !2, 2
         18        CONCAT                                           ~18     ~16, ~17
         19        SEND_VAL                                                 ~18
         20        DO_ICALL                                         $19     
         21        ASSIGN                                                   !5, $19
   15    22        CONCAT                                           ~21     'Letter+to+find%3A+', !3
         23        CONCAT                                           ~22     ~21, '%0AWord+to+find%3A+'
         24        CONCAT                                           ~23     ~22, !4
         25        CONCAT                                           ~24     ~23, '%0APosition+of+letter%3A+'
         26        CONCAT                                           ~25     ~24, !5
         27        ECHO                                                     ~25
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.79 ms | 1396 KiB | 17 Q