Myself
Myself

Reputation: 11

How to limit words in a echo field

I have this code, I need to limit the word in the field "newsContenuto" and add some"..." .

echo "<tr>";
        echo "<td>{$newsID}</td>";
        echo "<td>{$newsData}</td>";
        echo "<td>{$newsAutore}</td>";
        echo "<td>{$newsTitolo}</td>";
        echo "<td>{$newsContenuto}</td>";
        echo "<td>";

Upvotes: 1

Views: 72

Answers (1)

Mohammadreza Yektamaram
Mohammadreza Yektamaram

Reputation: 1514

Try this example:

echo "<td>" . substr( $newsContenuto, 0, 20 ) . "...</td>";

In the above code, I've set 20, you can increase that.

Upvotes: 3

Related Questions