pouncer Posted April 5, 2007 Share Posted April 5, 2007 function get_Keyword() { return $this->row['keyword']; } if the keyword is more then 10, i want it to show the first 10 letter with .. on the end of it, otherwise just to return the whole string? e.g keyword = "mr bean excellent DVD" the function should return: mr bean ex.. Quote Link to comment Share on other sites More sharing options...
utexas_pjm Posted April 5, 2007 Share Posted April 5, 2007 <?php // ... return (strlen($str) < 10 ? $str : substr($str, 0, 10)); // ... ?> Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 5, 2007 Share Posted April 5, 2007 <?php function get_keyWord($string){ if(strlen($string) > 10){ $string = substr($string, 0, 10) . '...'; } return $string; } get_keyWord($this->row['keyword']); ?> that should work. Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 5, 2007 Author Share Posted April 5, 2007 they didn't work guys, any ideas peeps? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 5, 2007 Share Posted April 5, 2007 How didn't it work? Please give us a hint. Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.