PHP Code To Limiting Words Number In PHP
This function can limiting words number. Usually this used to limit name of person. Here the code:
function word($word,$limit){
$result='';
$words=@explode(" ",$word);
for($i=0;$i<=$limit-1;$i++){
$result.=@$words[$i]." ";
}
return $result;
}
$name = "iben arief bin padi";
echo word($name,1); // output: iben
echo word($name,2); // output: iben arief
echo word($name,3); // output: iben arief bin
echo word($name,4); // output: iben arief bin padi
Good Luck !!!
$result='';
$words=@explode(" ",$word);
for($i=0;$i<=$limit-1;$i++){
$result.=@$words[$i]." ";
}
return $result;
}
$name = "iben arief bin padi";
echo word($name,1); // output: iben
echo word($name,2); // output: iben arief
echo word($name,3); // output: iben arief bin
echo word($name,4); // output: iben arief bin padi
0 comments:
Post a Comment