Modifying capitalize( ) to take a reference parameter : strtoupper « String « PHP
- PHP
- String
- strtoupper
Modifying capitalize( ) to take a reference parameter
<?php
function capitalize( &$str, $each=TRUE ){
{
$str = strtolower($str);
if ($each === true) {
$str = ucwords($str);
} else {
$str{0} = strtoupper($str{0});
}
}
$str = "hEllo WoRld!";
capitalize( $str );
echo $str;
?>
Related examples in the same category