YavorGrancharov

Capital-Case Words

Dec 2nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. <?php
  2.     if (isset($_GET['text'])) {
  3.         $text = $_GET['text'];
  4.         preg_match_all('/\w+/', $text, $words);
  5.         $words = $words[0];
  6.  
  7.         $upperWords = array_filter($words, function ($word){
  8.             return strtoupper($word) == $word;
  9.         });
  10.         echo implode(', ',$upperWords);
  11.     }
  12. ?>
  13. <form>
  14.     <textarea rows="10" name="text"><?=$upperWords?></textarea><br>
  15.     <input type="submit" value="Extract">
  16. </form>
Add Comment
Please, Sign In to add comment