以下回顯當前全部大寫,我如何強制第一個字母大寫,每個單詞的其餘小寫字母,但仍然限制使用substr或類似的東西的長度?在php中結合使用ucwords和substr
<?php echo substr($row['fulladdress'],0,20); ?>
以下回顯當前全部大寫,我如何強制第一個字母大寫,每個單詞的其餘小寫字母,但仍然限制使用substr或類似的東西的長度?在php中結合使用ucwords和substr
<?php echo substr($row['fulladdress'],0,20); ?>
應該這樣做。只需把它包在ucfirst功能
使用ucfirst()
和strtolower()
<?php echo substr(ucfirst(strtolower($row['fulladdress'])),0,20); ?>
像:<?php echo ucfirst(strtolower(substr($row['fulladdress'],0,20))); ?>
[你嘗試過什麼?](http://www.whathaveyoutried.com) – Matt
你意味着像「LOREM IPSUM DOLOR SIT AMET」這樣的字符串到'「Lorem Ipsum Dolor Si」'? –