Example
<?php
<body bgcolor="#CC99CC">
<font color="#993300" size="+2"><center>STRING FUNCTION DEMO</font><br><br>
</head>
<body>
<form id="form1" name="form1" method="get" action="">
<label>EnterString::
<textarea name="textarea"></textarea>
</label>
<label>ENTER SECOND STRING
<input type="text" name="tf" />
</label>
<label></label>
<p> </p>
<p>
<label>
<input type="submit" name="b1" value="Submit" />
</label>
</p>
</form>
if(isset($_GET["b1"]))
{
$tf=$_GET["tf"];
$s=$_GET["textarea"];
echo "1.LENGTH OF STRING IS::"." ".strlen($s)."<p>";
echo "2.REVERSE OF STRING IS::"." ".strrev($s)."<p>";
echo "3.UPPER CASE OF STRING::"." ".strtoupper($s)."<p>";
echo "4.LOWER CASE OF STRING::"." ".strtolower($s)."<p>";
echo "5.RETURN 0 IF BOTH STRING ARE SAME::"." ".strcmp($s,$tf)."<p>";
echo "6.REPEATATION OF STRING ::"." ".str_repeat($s,2)."<p>";
echo "7.CASE COMPARE::"." ".strcasecmp($s,$tf)."<p>";
echo "8.SUBSTRING::"." ".substr($s,1,4)."<p>";
$b=array('you','are',$tf,$s);
echo "9. USING JOIN::".join(" ",$b)."<p>";
echo "10. STRING REPLACE::".str_replace("sur",$tf,$s)."<p>";
}
?>
</body>
No comments:
Post a Comment