CodeIgniter Forums
print substring but show full words not cutted character..!! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: print substring but show full words not cutted character..!! (/showthread.php?tid=20414)



print substring but show full words not cutted character..!! - El Forum - 07-08-2009

[eluser]Zeeshan Rasool[/eluser]
Hi all,
I need little help from you.I want to print content of post but limited portion and after that i show a link "Read More" in end so that it leads to full post detail. But when i use substr() func and use 200 character it prints well but i need to print or need to end substring with full word

example:

Default:
This is my post and when it mak...ReadMore

I need:
This is my post and when it makes...ReadMore

One idea is to use array to store word by word but any idea from you guys!

thanks in advance:


print substring but show full words not cutted character..!! - El Forum - 07-09-2009

[eluser]Colin Williams[/eluser]
Do your substr, then loop backward, trimming until you reach a word breaking character.


print substring but show full words not cutted character..!! - El Forum - 07-09-2009

[eluser]Dam1an[/eluser]
You could always use thge character_limiter function in the text helper


print substring but show full words not cutted character..!! - El Forum - 07-09-2009

[eluser]Zeeshan Rasool[/eluser]
Thanks guys ! character_limiter() func is really workig well.