Word Limit of a string In PHP

undefined

Sometimes, if we need limit in the text, but if you are using the inbuilt functions of php then it breaks the words, and count only characters not the word. In this post you will see the very useful PHP function which can be used in limit of word. It counts word not counts the characters.

/*LIMIT TEXT*/

<?php
function countwordscustom($string, $limit) {
$str_code = explode(" ",$string); 
return implode("",array_splice($str_code,0,$limit)); 
}
?>
/*END LIMIT TEXT*/
If you want to use this function anywhere in your PHP file follow given example

<?php
$text = "Sabbay.co is a very good website the design of the website is very cool and good looking."; 
echo countwordscustom($text,10); 
?>
Save Url in CSV using IMACROS, iMacro JavaScript Extracting values ការប្រើ iMacro ដើម្បីបង្កើត csv file and adding new line - (0 comments)
DRAG AND DROP NESTABLE MENU ON PHP AND MYSQL AND JQUERY - (4 comments)
How to create Menu and Sub menu, How to use Recursion Function in Codeigniter recursive function, Php, MySQL - (0 comments)

0 comments:

Post a Comment

Followers

រឿង ដែលខានមើលមិនបាន

Contact us

Name

Email *

Message *

Your Language

Online

Copyright 2009 Simplex Celebs All rights reserved Designed by www.sruol9.com