- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我需要一些帮助我有这段代码,大写字符串中每个单词的第一个字符,但有异常(exception)我需要函数来忽略异常,如果它在字符串的开头:
function ucwordss($str, $exceptions) {
$out = "";
foreach (explode(" ", $str) as $word) {
$out .= (!in_array($word, $exceptions)) ? strtoupper($word{0}) . substr($word, 1) . " " : $word . " ";
}
return rtrim($out);
}
$string = "my cat is going to the vet";
$ignore = array("is", "to", "the");
echo ucwordss($string, $ignore);
// Prints: My Cat is Going to the Vet
这就是我正在做的:
$string = "my cat is going to the vet";
$ignore = array("my", "is", "to", "the");
echo ucwordss($string, $ignore);
// Prints: my Cat is Going to the Vet
// NEED TO PRINT: My Cat is Going to the Vet
最佳答案
- return rtrim($out);
+ return ucfirst(rtrim($out));
关于php - ucwords 函数有异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11996446/
目前,我正在使用与 ucwords 相关的函数在连字符、点和撇号之后制作大写字母: function ucwordsMore ($str){ $str = ucwords($str);
这个问题在这里已经有了答案: Make all words lowercase and the first letter of each word uppercase (3 个答案) 关闭去年。 我
我需要一些帮助我有这段代码,大写字符串中每个单词的第一个字符,但有异常(exception)我需要函数来忽略异常,如果它在字符串的开头: function ucwordss($str, $except
这个问题在这里已经有了答案: Make all words lowercase and the first letter of each word uppercase (3 个答案) 关闭去年。 在
我需要创建一个函数来读取顶部的变量并修复字符串,以便其中的每个单词都有一个大写字母。我目前这样做的方式似乎不起作用。这是我所拥有的: 有谁知道什么会导致输出仍然是小写? 最佳答案 您可以通过引用传递
我想在 JavaScript 中对以下形式的字符串执行 ucwords(),它应该返回 Test1_Test2_Test3。 我已经在 SO 上找到了一个 ucwords 函数,但它只需要空格作为新词
有人知道如何在 javascript () 中将 name1-name2-name3 转换为 name1Name2Name3 吗? (寻找优雅的解决方案) 谢谢 最佳答案 好的。改变了我的答案,因为我
我写这段代码 echo ucwords('online/offline'); 预期结果:在线/离线 结果:在线/离线 如何在不加空格的情况下让斜线符号后的第一个字母变成大写字母? 最佳答案 您可以在
在我的 $_POST 中,我想知道如何将 ucwords 应用于数组内的值“english”和“math”。 Array ( [name1] => Array
php ucwords() 函数将字符串中每个单词的首字符转换为大写, 本文章向码农介绍php ucwords() 函数的基本使用方法和实例,感兴趣的码农可以参考一下。 定义和用法 ucwor
一些奇怪的事情正在发生。实际上,我正在从异步调用中分配标题,并且正在应用 ucwords过滤标题。它给了我正确的输出,但首先抛出错误,然后显示正确的值。 HTML 片段: {{ defaultProd
这个问题在这里已经有了答案: Make all words lowercase and the first letter of each word uppercase (3 个答案) 关闭 1 年前
我想将“s.value”全部转为小写,然后转为 ucwords,但我不知道该怎么做,因为它在一个表单中。 基本上我想做这样的事情:ucwords(strtolower( s.value here ))
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: MySQL - Capitalize first letter of each word, in exist
我是一名优秀的程序员,十分优秀!