PHP: Split string into 2 section after specific length

by Jayanthi 2012-12-25 16:39:21

PHP: Split string into 2 section after specific lengthspecific

String split 2 sections:

First section have 100 characters.The second section of the string can be the remainder. Sometimes single word character split into first & second sections.

This code is not split words.



$para="HIOX INDIA, a leading business web hosting company, is currently involved in web services, software/application development, web content development, web hosting, domain registration, internet solutions and web design.";
if(strlen($para) > $length) {
echo "
Before :".$para;
$para_title1 = substr($para, 0,strpos($para, ' ', $length));
$para_title2=split ( $para_title1 , $para);
echo "

After :".$para_title1;
echo "

After :".$para_title2[1];

}
else
echo $para;

?>
918
like
0
dislike
0
mail
flag

You must LOGIN to add comments