Sub string in Php:
$str = "ghsdgdsgadsgdhg djahdjhajdh hdsjahdjahd hjkhdsajhd
ahdjsahdjahsdjahsdjashd jkdsajdahdjsahjhdsajh djash
djashdjhs hjdsahjdhasdh hjdsahdhsajdhjas jhdsjahdahdhs
jhdsjahdjahdjsa jhdsjahdjah djhsadjhadha hsjdha shdajsh
daasdas";
$ddd = sub_string($str);
function sub_string($str = '', $length = 150) {
if (!$str) {
return FALSE;
}
if (strlen($str) > $length)
return substr($str, 0, $length) . '...';
else
return $str;
}
$str = "ghsdgdsgadsgdhg djahdjhajdh hdsjahdjahd hjkhdsajhd
ahdjsahdjahsdjahsdjashd jkdsajdahdjsahjhdsajh djash
djashdjhs hjdsahjdhasdh hjdsahdhsajdhjas jhdsjahdahdhs
jhdsjahdjahdjsa jhdsjahdjah djhsadjhadha hsjdha shdajsh
daasdas";
$ddd = sub_string($str);
function sub_string($str = '', $length = 150) {
if (!$str) {
return FALSE;
}
if (strlen($str) > $length)
return substr($str, 0, $length) . '...';
else
return $str;
}
No comments:
Post a Comment