CyberFla
CyberFla

Reputation: 71

PHP text truncate limit characters

I have $Description field is a long text from MySql database. Following displays the full text but I really want to display only 50 characters instead of full text length.

 <?php  echo $row['Description'];?> 

I have tried several different options but I don't get any results.

I hope someone can guide me through this. Thank you for your time and help.

Sincerely,

Upvotes: 1

Views: 218

Answers (2)

ScaisEdge
ScaisEdge

Reputation: 133400

You can use a substr

<?php  echo substr($row['Description'], 0, 50);   ?>

Upvotes: 1

alexander.polomodov
alexander.polomodov

Reputation: 5534

Use substr function:

<?php  echo substr($row['Description'], 0, 50);?> 

Upvotes: 2

Related Questions