我在这里找到了答案:How to capitalize first letter of first word in a sentence?但是,当句子以"
或«
等字符开头时,它不起作用。PHP:如何将一个句子中第一个单词的首字母大写,包括一组非ASCII值?
在上面的链接找到的代码是:
$output = preg_replace('/([.!?])\s*(\w)/e', "strtoupper('\\1 \\2')", ucfirst(strtolower($input)));
下面是处理一个例子,我需要
$input => «the first article title»
$output => «The first article title»
$input => « the first article title »
$output => « The first article title »
$input => "être"
$output => "Étre"
的想法是忽略任何非字母(不即[az,AZ ] +法国字符)并适用于第一个字母,其余部分与输入保持一致。
什么是'$ input'内容?显示输入和预期输出 – RomanPerekhrest
使用输入=>输出示例更新问题。你不可能从评论中了解到你想要的。 – Dekel
['ucfirst()'](http://php.net/manual/en/function.ucfirst.php)呢? – axiac