1. write a php function to truncate a string to $n chars without using php inbuilt function.
The string may have <b> </b> tags also. If after truncation a word is cut, then it should be removed from outcome.
Also the output should be appended with </b> if there is a missing </b> tag as a result of truncation. No other tag needs to be handled.
// function declaration
function truncate_str ($str, $n) {
….
return $result;
}
function to truncate a string to n chars
Moderator: General Moderators
-
sathish.hc
- Forum Newbie
- Posts: 15
- Joined: Tue May 23, 2006 2:55 am
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
-
phpfanatico
- Forum Newbie
- Posts: 1
- Joined: Wed Aug 30, 2006 3:18 am