$text = 'This is an example of quite long text or sentence and we want to cut it to use as an excerpt';
$max_char = 45;
echo substr($text, 0, $max_char) . '...';
This site uses cookies to deliver our services and to show you relevant ads and job listings. By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, CODE 4B5F-01 (PRICE) our Terms of Service. Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.