2015-10-27 37 views
1

我一直在嘗試在PHP中做一些非常基礎的工作,因爲我是PHP的初學者,但是我沒有真正實現我的目標。 我想要做的是我有像..的字符串! 混合類型:如何在PHP中將全部大寫單詞字符串轉換爲ucwords?

THIS IS A SENTENCE 
tHis Is a SEnTenCe 

我真的試過在PHP ucwords功能,但是這並沒有給確切的結果作爲ucwords只注重每個單詞的第一個字母和單詞中不注重其他剩餘的字符..我真正想要的是從每種混合類型的字符串中獲得某種固定類型的字符串..!

像:

This Is A Sentence 

,也可以是我沒有檢查properly..So如果任何人都可以指導我在正確的path.That將是巨大的!

+0

如果你有一個字符串,如'這是一個來自句,美的,A'? 'ucwords(strtolower' will fail。 –

+0

@ Fred-ii- Well..What will the solution then for additional informations? –

+0

you've accepted an answer –

回答

4

轉換爲小寫第一:

$string = ucwords(strtolower($string)); 
3
<?php 
$l = 'tHis Is a SEnTenCe'; 
echo ucwords(strtolower($l)); 
?> 

結果

This Is A Sentence 
相關問題