Thursday, 15 August 2013

Counting number of characters using strlen() in php

In this post we have discussed how to count the number of characters in a particular paragraph using the function strlen() in php.
      Using the function strlen() in php,we can able to calculate and count the number of letters in the content.

Counting number of characters using strlen() in php

Lets see how the script works in the counting number of characters using the function strlen() in php and displaying the number.Here is the code for the counting the number of characters using strlen() in php.

Index :

<form name=aform method="post">
<table width="35%" border="0" cellspacing="0" cellpadding="10" id="tbl">
<tr><th scope="col">No of characters</th></tr>
<td>
<p>One of the important districts is Chennai District is located in the northeast of Tamil Nadu and is renowned as a tourist destination 
Thanjavur district is dotted with numerous temples and is also known for its arts and crafts. Salem district is rich in mineral deposits like magnesite, bauxite, limestone, soapstone, roughstone and granite  </p> 
</td>
</table>
<?php 
$para=("One of the important districts is Chennai District is located in the northeast of Tamil Nadu and is renowned as a tourist destination Thanjavur district is dotted with numerous temples and is also known for its arts and crafts. Salem district is rich in mineral deposits like magnesite, bauxite, limestone, soapstone, roughstone and granite .");
?>
<p align="center"  class="para">Number of characters : <?php echo strlen($para); ?></p>
</form>


#tbl
{
-moz-box-shadow: 0 0 0 1px #C8C8C8 inset;
-webkit-box-shadow: 0 0 0 1px #C8C8C8 inset;
box-shadow: 0 0 0 3px #C8C8C8 inset;
background: -webkit-linear-gradient(top, #FFF 0%,#F2F2F2 50%);
color:#009;
margin:10% auto;
}
.para{ color:#009;}


No comments:

Post a Comment