Monday, 10 December 2012

Display limited data through PHP

Using following function you can easily display limited data on your web page.

For example you have display only first 75 character then you have only need to call this function and define your DB variable & required no. of size need to be display.

$disData = display_limited_data($row['yourDBvariable'],'75')

function display_limited_data($data,$size)
{
if(strlen($data) >= $size){
$Stddata = substr($data,0,$size).'...';
}
else
{
$Stddata = $data;
}

return $Stddata;