diff --git a/functions/strings.xml b/functions/strings.xml index cea548a64d..82dfccd728 100644 --- a/functions/strings.xml +++ b/functions/strings.xml @@ -765,7 +765,9 @@ $colon_separated = implode (":", $array); This function strips whitespace from the start of a string and - returns the stripped string. + returns the stripped string. The whitespace + characters it currently strips are: "\n", "\r", "\t", "\v", "\0", + and a plain space. See also chop and trim. @@ -1373,12 +1375,22 @@ $formatted = sprintf ("%01.2f", $money); string str1 string str2 - + Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. - + + <function>strcasecmp</function> example + +$var1 = "Hello"; +$var2 = "hello"; +if ( !strcasecmp($var1,$var2) ) { + echo '$var1 is equal to $var2 in a case-insensitive string comparison'; +} + + + See also ereg, strcmp, substr, stristr, and @@ -2266,7 +2278,7 @@ echo substr_replace ($var, '', 10, -1) . "<br>\n"; This function strips whitespace from the start and the end of a string and returns the stripped string. The whitespace characters it currently strips are: "\n", "\r", "\t", "\v", "\0", - and " ". + and a plain space. See also chop and @@ -2296,6 +2308,13 @@ echo substr_replace ($var, '', 10, -1) . "<br>\n"; Note that 'alphabetic' is determined by the current locale. For instance, in the default "C" locale characters such as umlaut-a (ä) will not be converted. + + <function>ucfirst</function> example + +$text = 'mary had a little lamb and she loved it so.'; +$text = ucfirst($text); // $text is now Mary had a little lamb and she loved it so. + + See also strtoupper and @@ -2317,10 +2336,17 @@ echo substr_replace ($var, '', 10, -1) . "<br>\n"; string ucwords string str - + Capitalizes the first character of each word in str if that character is alphabetic. - + + <function>ucwords</function> example + +$text = "mary had a little lamb and she loved it so."; +$text = ucwords($text); // $text is now: Mary Had A Little Lamb And She Loved It So. + + + See also strtoupper, strtolower and ucfirst.