$strScentence="My Name is Ritesh Kumar Sahu";
$limit=4; // number or words
$strLimit=limitScentence($strScentence,$limit);
echo $strLimit;
/*------------ function to limit the scentence -------------*/
function limitScentence($strScentence,$limit)
{
$arrWords=preg_split("/\s+/", $strScentence);
if(count($arrWords)<$limit)
{
return $strScentence;
}
$strLimitScentence="";
for($i=0;$i<$limit;$i++)
{
$strLimitScentence.=$arrWords[$i]." ";
}
$strLimitScentence=substr($strLimitScentence,0,strlen($strLimitScentence)-1);
return $strLimitScentence;
}
/*------------- Created By Ritesh Kumar Sahu-------------*/
?>
good code
ReplyDeleteNice code, it saves lots of my time
ReplyDeleteAshwani Pradhan
SE(Internal projects)
Synapse India
Hi Ritesh,
ReplyDeleteThis is with reference to your candidature. We are delighted to inform that you have been short listed for the post of Software Engineer.
You are requested to come for the interview. The details are mentioned below:
Venue: H-23, Sector-63, Noida, Behind Bikanerwala
Time- 7:30 PM /08.09.08
Contact Person: Sarika
sdfgsdfgfdg
ReplyDeletedrag & drop
ReplyDelete