Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php shorten string with dots

function preview($text)
// we don't want new lines in our preview
$text_only_spaces = preg_replace('/s+/', ' ', $text);
// truncates the text
$text_truncated = mb_substr($text_only_spaces, 0, mb_strpos($text_only_spaces, " ", 50));
// prevents last word truncation
$preview = trim(mb_substr($text_truncated, 0, mb_strrpos($text_truncated, " ")));
$preview."...";
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel add column to table 
Php :: csv utf-8 excel into php 
Php :: upload multiple files in codeigniter 
Php :: php print all woocommerce products 
Php :: valdidate laravel if falid 
Php :: php code for video upload 
Php :: Instalar Lamp server en Ubuntu 
Php :: laravel generate unique db token 
Php :: atualizar versão do php no linux 
Php :: How to disable Gutenberg / block editor for certain post types 
Php :: use font awesome in laravel 8 
Php :: stdclass not found laravel 
Php :: php add to multidimensional array 
Php :: General error: 1390 Prepared statement contains too many placeholders 
Php :: laravel blade @selected 
Php :: php online editor 
Php :: simple_form_for id 
Php :: filter collection (laravel) 
Php :: search in laravel 8 
Php :: print in php 
Php :: how to delete empty rows in phpmyadmin 
Php :: drupal 8 user_load 
Php :: laravel model sync 
Php :: named route with parameter laravel 
Php :: how to remove duplicate values from a multidimensional array in php 
Php :: query relationships laravel and select some columns 
Php :: how to get structure of table in codeigniter 
Php :: php italian date 
Php :: laravel find duplicate rows 
Php :: max title limit woocommerce product 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =