Advance String functions:
Here I am going to explain the Advance use and codes of string , you can just try this code and can learn the string functions. you can simply copy this code and use this code in Notepad++ and Dreamweaver and any other software that you have:-Example:
<!DOCTYPE html>
<html >
<head>
<title>String Funtion</title>
</head>
<body>
<?php
error_reporting(0);
if(isset($_REQUEST['submit']))
{
$value=$_REQUEST['value'];
$radiobutton=$_REQUEST[radiobutton];
if(empty($value))
{
echo"<script>alert('please enter the text in text box')</script>";
}
else
{
switch($_REQUEST['radiobutton'])
{
case 1:
echo strlen($value);
break;
case 2:
echo strrev($value);
break;
case 3:
echo ucwords($value);
break;
case 4:
echo ucfirst($value);
break;
case 5:
echo strtoupper($value);
break;
case 6:
echo str_word_count($value);
break;
case 7:
echo strtolower($value);
break;
}
}
}
?>
<form id="form1" name="form1" method="post" action="">
<table width="100%" height="96" border="1">
<tr>
<td width="30%" height="28">enter number </td>
<td width="70%"><label>
<input name="value" type="text" id="value" />
</label></td>
</tr>
<tr>
<td height="29" colspan="2"><label>
<input name="radiobutton" type="radio" value="1"
<?php if($radiobutton==1){ ?>
checked="checked"
<?php } ?> >
strlen
<input name="radiobutton" type="radio" value="2"
<?php if($radiobutton==1){ ?> checked="checked" <?php } ?> >
strrev
<input name="radiobutton" type="radio" value="3"
<?php if($radiobutton==1){ ?> checked="checked" <?php } ?> >
uc words
<input name="radiobutton" type="radio" value="4"
<?php if($radiobutton==1){ ?> checked="checked" <?php } ?> >
ucfirst
<input name="radiobutton" type="radio" value="5"
<?php if($radiobutton==1){ ?> checked="checked" <?php } ?> >
strtoupper
<input name="radiobutton" type="radio" value="6"
<?php if($radiobutton==1){ ?> checked="checked" <?php } ?> >
str_word_count
<input name="radiobutton" type="radio" value="7"
<?php if($radiobutton==1){ ?> checked="checked" <?php } ?> >
strtolower </td>
</tr>
<tr>
<td height="29"> </td>
<td><label>
<input name="submit" type="submit" id="submit" value="Submit" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
Comments