RsD0p9BK
5/6/2015 - 10:15 AM

preg__capitalize.php

// preg_replace capitalize a letter

$str = 'JAMES "JIMMY" SMITH';
echo preg_replace_callback(
  '/\b[a-z]/', 
  function ($matches) {
    return strtoupper($matches[0]);
  }, 
  $str
);

// http://stackoverflow.com/questions/2638288/preg-replace-to-capitalize-a-letter-after-a-quote