fork(4) download
  1. <?php
  2.  
  3. $str = 'he said "hello WORLD"';
  4. $str = strtolower($str); // first lowercase everything
  5. echo preg_replace('/\b([a-z])/e', 'strtoupper(\'$1\')', $str);
  6.  
  7. echo "\n";
  8.  
  9. $str = 'he said "καλημέρα ΚΌΣΜΕ"'; // this has to be in UTF-8
  10. $str = mb_convert_case($str, MB_CASE_LOWER, 'UTF-8');
  11. echo preg_replace('/(?<!\p{L})(\p{Ll})/eu',
  12. 'mb_convert_case(\'$1\', MB_CASE_UPPER, \'UTF-8\')',
  13. $str);
  14.  
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
He Said "Hello World"
He Said "Καλημέρα Κόσμε"