Capitalize first letter of a string (preceded with special characters) - PHP
I'd like to capitalize a string like: ¿"hello"? I want my function to return ¿"Hello"? I've tried with regex and preg_match, with no luck... Here it is my previous question, related with this one: "preg_match is matching two characters when it should only match one" Thank you all! You can do it using preg_replace_callback : preg_replace_callback('/^([^a-z]*)([a-z])/i', function($matches){ return $matches[1] . strtoupper($matches[2]); }, '¿"hello"?'); // ¿"Hello"? Using preg_replace_callback as said ascii-time above, but unicode compatible: echo preg_replace_callback('/^(\PL*)(\pL)/u', function