php字符串按照單詞進行反轉的方法_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:php將數組轉換成csv格式文件輸出的方法本文實例講述了php將數組轉換成csv格式文件輸出的方法。分享給大家供大家參考。具體實現方法如下: ?php$sales = array( array('east','2005-01-01','2005-02-01',12.54), array('west','2005-01-01','2005-02-01',546.33), array('south','2005-01-01','2005-02-01',9
本文實例講述了php字符串按照單詞進行反轉的方法。分享給大家供大家參考。具體分析如下:
下面的php代碼可以將字符串按照單詞進行反轉輸出,實際上市現將字符串按照空格分隔到數組,然后對數組進行反轉輸出
<?php $s = "Reversing a string by word"; // break the string up into words $words = explode(' ',$s); // reverse the array of words $words = array_reverse($words); // rebuild the string $s = implode(' ',$words); print $s; ?>輸出結果如下:
word by string a Reversing
希望本文所述對大家的php程序設計有所幫助。
分享:php實現字符串首字母大寫和單詞首字母大寫的方法本文實例講述了php實現字符串首字母大寫和單詞首字母大寫的方法。分享給大家供大家參考。具體分析如下: ucfirst可以對字符串首字母進行大小,ucwords可以對字符串中每個單詞的首字母大寫輸出 ?phpprint ucfirst(hello world);print ucwords(iam king of the jungle);?
相關PHP教程:
- 相關鏈接:
- 教程說明:
PHP教程-php字符串按照單詞進行反轉的方法
。