Friday, 9 August 2013

Displaying a maximum amount of characters using substr() in php

In this post we have discussed about how the content is viewed by onclicking the link, more.In a paragraph we used to keep some particular lines then we will keep readmore link,by clicking on that link more the remaining content will displayed below.
     To view minimum lines visible and the maximun lines invisible using the function substring().

Displaying a maximum amount of characters using substr() in php



By using the substring fuction we can able to view the maximum content in the particular paragraph.
Function is substr().

<form name="aform" method="post" >
  <?php  $para=("Tamil Nadu is amongst the 28 states of India and is the 11th sate in the country and ranked 7th in terms of population. Tamil Nadu occupies the extreme south of the Indian peninsula and has a rich cultural heritage. Bharatnatyam and Carnatic Music have flourished here for centuries. The state is also famous for its handicrafts made of wood, stone and metal. This state is also the source of forest products like sandalwood, timber, fuel-wood and crops like, sugarcane, groundnut, potatoes and spices. Tamil Nadu state is divided into 32 districts. 
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 and Tamil Nadu is amongst the 28 states of India and is the 11th sate in the country and ranked 7th in terms of population. Tamil Nadu occupies the extreme south of the Indian peninsula and has a rich cultural heritage. Bharatnatyam and Carnatic Music have flourished here for centuries. The state is also famous for its handicrafts made of wood, stone and metal. This state is also the source of forest products like sandalwood, timber, fuel-wood and crops like, sugarcane, groundnut, potatoes and spices. Tamil Nadu state is divided into 32 districts. 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");
echo substr($para,0,50)."....<a href='$para'>more</a>"; 
 ?>
</form>