3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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;
based on PuNJc
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0rc6
Letter to find: P Word to find: PHP Position of letter: 80