|
|
|
|
<< < 2014 - 6 > >>
日 |
一 |
二 |
三 |
四 |
五 |
六 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
|
|
|
|
|
|
|
|
|
|
|
|
- <?php
-
- //$text: 字符串变量,代表需要转换的文本。
// $type: 字符串,代表转换的类型: // -u 将把所有字母转换为大写; // -l 将把所有字母转换为小写; // -w 将把每个单词的第一个字母转换为大写。 // -s 将把每个语句的第一个字母转换为大写。
-
- $text = "THE SUN WAS SHINING ON THE SEA, SHINING WITH ALL HIS MIGHT: HE DID HIS VERY BEST TO MAKE THE BILLOWS SMOOTH AND BRIGHT - AND THIS WAS ODD, BECAUSE IT WAS THE MIDDLE OF THE NIGHT. THE MOON WAS SHINING SULKILY, BECAUSE SHE THOUGHT THE SUN HAD GOT NO BUSINESS TO BE THERE AFTER THE DAY WAS DONE";
-
- echo PIPHP_CapsControl($text, "u") . "<br />";
- echo PIPHP_CapsControl($text, "l") . "<br />";
- echo PIPHP_CapsControl($text, "w") . "<br />";
- echo PIPHP_CapsControl($text, "s") . "<br />";
-
- PIPHP_CapsControl($text, $type)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
- switch($type)
- {
- case "u": return strtoupper($text);
-
- case "l": return strtolower($text);
-
- case "w":
- $newtext = "";
- $words = explode(" ", $text);
- foreach($words as $word)
- $newtext .= ucfirst(strtolower($word)) . " ";
- return rtrim($newtext);
-
- case "s":
- $newtext = "";
- $sentences = explode(".", $text);
- foreach($sentences as $sentence)
- $newtext .= ucfirst(ltrim(strtolower($sentence))) . ". ";
- return rtrim($newtext);
- }
-
- return $text;
- }
-
- ?>
|
|
|