I am trying to use ucfirst on my variable:
$subject = ucfirst($_POST[‘subject’]);
it dosnt seem to work properly for example:
I type test it outputs to Test - which is fine.
I type tEsT and it outputs as TEsT.
how can I change it so no matter what I type it outputs the first letter as a capital and the rest lowercase?
$subject = ucfirst(strtolower($_POST['subject']));
Just in case the title has more than one word:
// From the manual: “http://www.php.net/manual/en/function.ucwords.php”
<?php
echo '<br />',
$bar = 'what is the meaning of life?'; // what is the meaning of life?
echo '<br />',
$bar = strtoupper($bar); // WHAT IS THE MEANING OF LIFE?
echo '<br />',
$bar = ucwords($bar); // WHAT IS THE MEANING OF LIFE?
echo '<br />',
$bar = ucwords(strtolower($bar)); // What Is The Meaning Of Life?
?>