Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. <?php
  2.  
  3. // This will make sure the value returned is an array
  4. function wordsToUpper($string) : array {
  5. if (empty($string) || is_null($string)) {
  6. return [];
  7. }
  8. $string = explode(' ', $string);
  9. return array_map('strtoupper', $string);
  10. }
  11.  
  12. $input = '';
  13.  
  14. $converted = wordsToUpper($input);
  15. echo '<pre>';
  16. print_r($converted);
  17. echo '</pre>';
  18.  
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement