/ Published in: PHP
Cut text to specific length.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Cut text to specific length. * * @param string $str The text to cut. * @param int $limit The maximum number of characters that must be returned. * @param stirng $br_char The character to use for breaking the string. * @param string $pad The string to use at the end of the cutted string. * @return string */ function cut_text($str, $limit, $br_char = '', $pad = '...') { } $text1 = 'Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut laboredo.'; // Normal usage: // Using an space for break the string: