在文本输入中将每个单词的首字母大写

时间:2020-07-13 14:24:40

标签: php html

我有一个数据库,用于存储当前文本输入的输入:

<input type="text" name="fullname" class="form-control" value="<?php echo $fullname; ?>" required>

是否可以在每篇作品中大写第一个字母,所以如果用户输入James bondjames bond,输出将为James Bond

我了解style="text-transform: capitalize;",但是据我了解,这只会更改显示的字母,但是表单数据中的实际数据仍将是用户输入的字母。

1 个答案:

答案 0 :(得分:0)

ucwords()是您要寻找的东西。

https://www.php.net/manual/en/function.ucwords.php

<input type="text" name="fullname" class="form-control" value="<?php echo ucwords($fullname); ?>" required>