https://jumnuoy.blogspot.com/2013/09/word-limit-of-string-in-php.html
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.
If you want to use this function anywhere in your PHP file follow given example/*LIMIT TEXT*/ <?php function countwordscustom($string, $limit) { $str_code = explode(" ",$string); return implode("",array_splice($str_code,0,$limit)); } ?> /*END LIMIT TEXT*/
<?php $text = "Sabbay.co is a very good website the design of the website is very cool and good looking."; echo countwordscustom($text,10); ?>
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.
If you want to use this function anywhere in your PHP file follow given example/*LIMIT TEXT*/ <?php function countwordscustom($string, $limit) { $str_code = explode(" ",$string); return implode("",array_splice($str_code,0,$limit)); } ?> /*END LIMIT TEXT*/
PHP<?php $text = "Sabbay.co is a very good website the design of the website is very cool and good looking."; echo countwordscustom($text,10); ?>
0 comments:
Post a Comment