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
<source lang="html4strict">
<?php
$submittedpass = "myPass"; $newpass = strtolower ($submittedpass); echo $newpass . "
"; $astring = "hello world"; echo ucfirst ($astring) . "
"; $astring = "hello world"; echo ucwords ($astring);
?>
</source>
Prettifying names with ucwords()
<source lang="html4strict">
<? print ucwords(strtolower("JOHN FRANKENHEIMER")); ?>
</source>
string ucwords ( string str ) converts the first letter of each word in the string to an uppercase character, leaving the others untouched.
<source lang="html4strict">
<?
$string = "i like to program in PHP"; $a = strtoupper($string);
?>
</source>
submitted string lowercase with strtolower() before invoking ucwords():
<source lang="html4strict">
<?php $full_name = "tHis IS a tESt"; $full_name = ucwords( strtolower($full_name) ); print $full_name; ?>
</source>
ucwords() function capitalizes the first letter of each word in a string.
<source lang="html4strict">
Its syntax is: string ucwords (string string) <? $sentence = "cooking and programming"; $sentence = ucwords($sentence); print $sentence; ?>
</source>
ucwords() makes the first letter of every word in a string uppercase.
<source lang="html4strict">
<?php $full_name = "this is a test"; $full_name = ucwords ( $full_name ); print $full_name; ?>
</source>
ucwords.php
<source lang="html4strict">
<?php
$title = "asdf asdf asdf!"; echo ucwords($title);
?>
</source>