How to get the words form a string that has multiple uppercase letters in PHP

1 Answer

0 votes
$string = 'PHP is a ScripTing language for web development. It was created by Rasmus Lerdorf';
    
$words = explode(' ',  $string);

foreach($words as $word) {
    if (preg_match('/[A-Z]/', $word)) {
        echo $word . "\n";
    }
}




/*
run:

PHP
ScripTing
It
Rasmus
Lerdorf

*/

 



answered Jul 11, 2023 by avibootz
...