PHP/String/ucwords
Содержание
- 1 Controlling Case
- 2 Prettifying names with ucwords()
- 3 string ucwords ( string str ) converts the first letter of each word in the string to an uppercase character, leaving the others untouched.
- 4 submitted string lowercase with strtolower() before invoking ucwords():
- 5 ucwords() function capitalizes the first letter of each word in a string.
- 6 ucwords() makes the first letter of every word in a string uppercase.
- 7 ucwords.php
Controlling Case
<?php
$submittedpass = "myPass";
$newpass = strtolower ($submittedpass);
echo $newpass . "<br />";
$astring = "hello world";
echo ucfirst ($astring) . "<br />";
$astring = "hello world";
echo ucwords ($astring);
?>
Prettifying names with ucwords()
<?
print ucwords(strtolower("JOHN FRANKENHEIMER"));
?>
string ucwords ( string str ) converts the first letter of each word in the string to an uppercase character, leaving the others untouched.
<?
$string = "i like to program in PHP";
$a = strtoupper($string);
?>
submitted string lowercase with strtolower() before invoking ucwords():
<?php
$full_name = "tHis IS a tESt";
$full_name = ucwords( strtolower($full_name) );
print $full_name;
?>
ucwords() function capitalizes the first letter of each word in a string.
Its syntax is: string ucwords (string string)
<?
$sentence = "cooking and programming";
$sentence = ucwords($sentence);
print $sentence;
?>
ucwords() makes the first letter of every word in a string uppercase.
<?php
$full_name = "this is a test";
$full_name = ucwords ( $full_name );
print $full_name;
?>
ucwords.php
<?php
$title = "asdf asdf asdf!";
echo ucwords($title);
?>