We can do this with the help of text helper in codeigniter
This helper is loaded using the following code:
$this->load->helper(‘text’);

1
2
3
4
5
6
 
$string = "I'm Premjith.K.K. Working as software engineer in sesame technologies pvt ltd calicut,Kerala,India. I have good knowledge and skills in PHP and its frame works such as Codeigniter, Wordpress, Cakephp etc and also have knowledge in c#.net. Using these skills I can convert your ideas to websites and web applications.";
 
$string = word_limiter($string, 6);
 
// Returns: I'm Premjith.K.K. Working as software engineer…

if you want to do the same in core php code with out any frame works

Do like this

1
2
3
4
5
6
7
8
9
10
11
 
$string = "I'm Premjith.K.K. Working as software engineer in sesame technologies pvt ltd calicut,Kerala,India. I have good knowledge and skills in PHP and its frame works such as Codeigniter, Wordpress, Cakephp etc and also have knowledge in c#.net. Using these skills I can convert your ideas to websites and web applications.";
 
 
       $inputstring			= strip_tags ($string);
       $pieces 				= explode(" ", $inputstring);
       $first_part 			= implode(" ", array_splice($pieces, 0, 6));
 
 
 
// Returns: I'm Premjith.K.K. Working as software engineer…
Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *

85 − 79 =