I've got a site where I'm listing game titles, and also, since each title is bigger than our needed space I must make use of the following code to interrupt it lower if it's bigger than some figures, after which show ...:

<?php $title = get_the_title(); echo mb_strimwidth($title, 0, 45, '...'); ?>

It is possible to method to possibly list only some words, rather than figures, therefore we can at any rate possess a full word in the finish from the title rather than a personality after which ...?

Any help could be greatly appreciated. This really is on the Wordpress system.

You can for instance use wordwrap() function after which discard all lines except the first.

This is a type of question, requested and clarified many occasions on SO. Listed here are two solutions:

Trim headline to nearest word
Trimming a block of text to the nearest word when a certain character limit is reached?

Since you are using multi-byte string functions, that you can do:

if (mb_strlen($title) > 45) {
    $title = mb_substr($title, 0, 45);
    // make sure it ends in a word by chomping at last space
    $title = mb_substr($title, 0, mb_strrpos($title, " ")).'...';

echo $title;