Page 1 of 1

how to convert variable value from lower case to upper case

Posted: Fri Dec 05, 2008 9:10 am
by Tassadduq
i have a variable $upper.
i have created a table of 2 rows and 2 columns.
the value of the variable is as
$upper ="pakistan";
now i want to display the value of this variable in the table in the upper case form.
how to do this?
here is my code please notify me where i am wrong.




<html>
<head>
<title>Variables Type<?php echo "$page";?></title>
</head>
<body>
<?php
$upper ="pakistan";
$replace1into2 ="He is the best";
$subtract =("hello,2,4");
$occurances ="pakistan is my country. i love pakistan.";
$s ="abc abc";
$firstupper ="tassadduq hussain";
$eachupper ="my name is tassadduq";


?>
<?php
echo "<table width='80%' border='1'>
<tr>
<td bgcolor=666666>Orignal Values</td>
<td bgcolor=666666>Result</td>
</tr>
<tr>
<td>echo "strtoupper ("$upper")";</td>
<td>&nbsp;</td>
</tr>
</table>";
?>
</body>
</html>

Re: how to convert variable value from lower case to upper case

Posted: Fri Dec 05, 2008 9:28 am
by Tassadduq
thnaks for views
i tried it again and again
and finally do it.


i create two variable
$upper ="pakistan";
$upperresult =strtoupper ("$upper");
and simply echo the $upperresult.
here is correct code but if anyone have easy way to do this then please reffer me.


<html>
<head>
<title>Variables Type<?php echo "$page";?></title>
</head>
<body>
<?php
$upper ="pakistan";
$upperresult = strtoupper ("$upper");
?>
<?php
echo "<table width='80%' border='1'>
<tr>
<td bgcolor=666666>Orignal Values</td>
<td bgcolor=666666>Result</td>
</tr>
<tr>
<td>$upperresult</td>
<td>&nbsp;</td>
</tr>
</table>";
?>
</body>
</html>

Re: how to convert variable value from lower case to upper case

Posted: Fri Dec 05, 2008 11:44 am
by watson516
Tassadduq wrote:thnaks for views
i tried it again and again
and finally do it.


i create two variable
$upper ="pakistan";
$upperresult =strtoupper ("$upper");
and simply echo the $upperresult.
here is correct code but if anyone have easy way to do this then please reffer me.


<html>
<head>
<title>Variables Type<?php echo "$page";?></title>
</head>
<body>
<?php
$upper ="pakistan";
$upperresult = strtoupper ("$upper");
?>
<?php
echo "<table width='80%' border='1'>
<tr>
<td bgcolor=666666>Orignal Values</td>
<td bgcolor=666666>Result</td>
</tr>
<tr>
<td>$upperresult</td>
<td>&nbsp;</td>
</tr>
</table>";
?>
</body>
</html>
If you have a bunch of html that you want printed with some php values in there, you should probably do...

Code: Select all

 
...
<?php
    $upper ="pakistan";
    $upperresult = strtoupper ("$upper");
?>
<table width='80%' border='1'>
  <tr>
    <td bgcolor=666666>Orignal Values</td>
    <td bgcolor=666666>Result</td>
  </tr>
  <tr>
    <td><?php echo $upperresult; ?></td>
    <td>&nbsp;</td>
  </tr>
</table>
...
 

Re: how to convert variable value from lower case to upper case

Posted: Fri Dec 05, 2008 12:15 pm
by Tassadduq
for what i use this?
my function is used for converting lower case words to upper case only.
here is all code of my page.
in this page i just create a table of five rows and two columns.
first row contains the name of fields.
first column contains the original values and second column function result.





Code: Select all

 
<html>
<head>
    <title>Variables Type<?php echo "$page";?></title>
</head>
<body>
<?php
    $upper ="pakistan";
    $upperresult = strtoupper ("$upper");
    $replace1into2 ="Respect Your Elders";
    $replace1into2result =strtr ($replace1into2, "Y", "F");
    $subtract ="Table";
    $subtractresult =substr ("$subtract",1);
    $occurance ="Pakistan is my country. i love Pakistan.";
    $occurancewith ="Pakistan";
    $occuranceresult = substr_count ($occurance, $occurancewith);
    $s ="abc abc";
    $firstupper ="tassadduq hussain";
    $eachupper ="my name is tassadduq";
    
 
?>
<?php
echo "<table width='80%' border='1'> 
  <tr>
    <td bgcolor=666666>Orignal Values</td>
    <td bgcolor=666666>Result</td>
  </tr>
  <tr>
    <td>$upper</td>
    <td>$upperresult</td>
  </tr>
   <tr>
    <td>$replace1into2</td>
    <td>$replace1into2result</td>
  </tr>
   <tr>
    <td>$subtract</td>
    <td>$subtractresult</td>
  </tr>
    <tr>
    <td>$occurance</td>
    <td>The word Pakistan is written $occuranceresult times</td>
  </tr>  
</table>";
?>
</body>
</html>

Re: how to convert variable value from lower case to upper case

Posted: Fri Dec 05, 2008 1:48 pm
by airy
why not to user

Code: Select all

strtoupper("anything");
instead of

Code: Select all

 
$str = "anything";
strtoupper("$str");